Added the totpEnabled field & added a default value for the totpSecret to the Account.ts

This commit is contained in:
Mathias Wagner 2023-01-21 13:16:22 +01:00
parent 0139ac6f6b
commit d9f8447dd2
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -1,6 +1,7 @@
import {Schema, ObjectId, model} from "mongoose";
import { fieldEncryption } from "mongoose-field-encryption";
import * as process from "process";
import speakeasy from "speakeasy";
export interface IAccount {
_id: ObjectId,
@ -9,7 +10,8 @@ export interface IAccount {
password: string,
verified: boolean,
verificationSecret: number | undefined,
totpSecret?: string
totpSecret?: string,
totpEnabled: boolean
}
const AccountSchema = new Schema<IAccount>({
@ -33,7 +35,14 @@ const AccountSchema = new Schema<IAccount>({
type: Boolean,
default: false
},
totpSecret: String
totpSecret: {
type: String,
default: () => speakeasy.generateSecret({name: "LicenseAPI"}).base32
},
totpEnabled: {
type: Boolean,
default: false
}
});
AccountSchema.plugin(fieldEncryption, {