From d9f8447dd259a3dad7f74c690468c94b4ead950a Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sat, 21 Jan 2023 13:16:22 +0100 Subject: [PATCH] Added the totpEnabled field & added a default value for the totpSecret to the Account.ts --- src/models/Account.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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, {