Implemented multiple app passwords.
All checks were successful
farmcontrol/farmcontrol-ws/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-ws/pipeline/head This commit looks good
This commit is contained in:
parent
289673813a
commit
028fa9dd94
22
src/database/schemas/management/apppassword.schema.js
Normal file
22
src/database/schemas/management/apppassword.schema.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import mongoose from 'mongoose';
|
||||||
|
import { generateId } from '../../utils.js';
|
||||||
|
const { Schema } = mongoose;
|
||||||
|
|
||||||
|
const appPasswordSchema = new mongoose.Schema(
|
||||||
|
{
|
||||||
|
_reference: { type: String, default: () => generateId()() },
|
||||||
|
name: { type: String, required: true },
|
||||||
|
user: { type: Schema.Types.ObjectId, ref: 'user', required: true },
|
||||||
|
active: { type: Boolean, required: true, default: true },
|
||||||
|
secret: { type: String, required: true, select: false },
|
||||||
|
},
|
||||||
|
{ timestamps: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
appPasswordSchema.virtual('id').get(function () {
|
||||||
|
return this._id;
|
||||||
|
});
|
||||||
|
|
||||||
|
appPasswordSchema.set('toJSON', { virtuals: true });
|
||||||
|
|
||||||
|
export const appPasswordModel = mongoose.model('appPassword', appPasswordSchema);
|
||||||
@ -10,6 +10,7 @@ const userSchema = new mongoose.Schema(
|
|||||||
lastName: { required: false, type: String },
|
lastName: { required: false, type: String },
|
||||||
email: { required: true, type: String },
|
email: { required: true, type: String },
|
||||||
profileImage: { type: mongoose.SchemaTypes.ObjectId, ref: 'file', required: false },
|
profileImage: { type: mongoose.SchemaTypes.ObjectId, ref: 'file', required: false },
|
||||||
|
appPasswordHash: { type: String, required: false, select: false },
|
||||||
},
|
},
|
||||||
{ timestamps: true }
|
{ timestamps: true }
|
||||||
);
|
);
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import { stockAuditModel } from './inventory/stockaudit.schema.js';
|
|||||||
import { partStockModel } from './inventory/partstock.schema.js';
|
import { partStockModel } from './inventory/partstock.schema.js';
|
||||||
import { auditLogModel } from './management/auditlog.schema.js';
|
import { auditLogModel } from './management/auditlog.schema.js';
|
||||||
import { userModel } from './management/user.schema.js';
|
import { userModel } from './management/user.schema.js';
|
||||||
|
import { appPasswordModel } from './management/apppassword.schema.js';
|
||||||
import { noteTypeModel } from './management/notetype.schema.js';
|
import { noteTypeModel } from './management/notetype.schema.js';
|
||||||
import { noteModel } from './misc/note.schema.js';
|
import { noteModel } from './misc/note.schema.js';
|
||||||
import { notificationModel } from './misc/notification.schema.js';
|
import { notificationModel } from './misc/notification.schema.js';
|
||||||
@ -134,6 +135,13 @@ export const models = {
|
|||||||
referenceField: '_reference',
|
referenceField: '_reference',
|
||||||
label: 'User',
|
label: 'User',
|
||||||
},
|
},
|
||||||
|
APP: {
|
||||||
|
model: appPasswordModel,
|
||||||
|
idField: '_id',
|
||||||
|
type: 'appPassword',
|
||||||
|
referenceField: '_reference',
|
||||||
|
label: 'App Password',
|
||||||
|
},
|
||||||
NTY: {
|
NTY: {
|
||||||
model: noteTypeModel,
|
model: noteTypeModel,
|
||||||
idField: '_id',
|
idField: '_id',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user