diff --git a/src/models/Account.ts b/src/models/Account.ts index 946b09d..2488b0b 100644 --- a/src/models/Account.ts +++ b/src/models/Account.ts @@ -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({ @@ -33,7 +35,14 @@ const AccountSchema = new Schema({ type: Boolean, default: false }, - totpSecret: String + totpSecret: { + type: String, + default: () => speakeasy.generateSecret({name: "LicenseAPI"}).base32 + }, + totpEnabled: { + type: Boolean, + default: false + } }); AccountSchema.plugin(fieldEncryption, {