Added the totpEnabled field & added a default value for the totpSecret to the Account.ts
This commit is contained in:
parent
0139ac6f6b
commit
d9f8447dd2
@ -1,6 +1,7 @@
|
|||||||
import {Schema, ObjectId, model} from "mongoose";
|
import {Schema, ObjectId, model} from "mongoose";
|
||||||
import { fieldEncryption } from "mongoose-field-encryption";
|
import { fieldEncryption } from "mongoose-field-encryption";
|
||||||
import * as process from "process";
|
import * as process from "process";
|
||||||
|
import speakeasy from "speakeasy";
|
||||||
|
|
||||||
export interface IAccount {
|
export interface IAccount {
|
||||||
_id: ObjectId,
|
_id: ObjectId,
|
||||||
@ -9,7 +10,8 @@ export interface IAccount {
|
|||||||
password: string,
|
password: string,
|
||||||
verified: boolean,
|
verified: boolean,
|
||||||
verificationSecret: number | undefined,
|
verificationSecret: number | undefined,
|
||||||
totpSecret?: string
|
totpSecret?: string,
|
||||||
|
totpEnabled: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const AccountSchema = new Schema<IAccount>({
|
const AccountSchema = new Schema<IAccount>({
|
||||||
@ -33,7 +35,14 @@ const AccountSchema = new Schema<IAccount>({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
totpSecret: String
|
totpSecret: {
|
||||||
|
type: String,
|
||||||
|
default: () => speakeasy.generateSecret({name: "LicenseAPI"}).base32
|
||||||
|
},
|
||||||
|
totpEnabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
AccountSchema.plugin(fieldEncryption, {
|
AccountSchema.plugin(fieldEncryption, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user