Add docs for MFA

This commit is contained in:
Tuan Dang
2023-02-21 16:08:09 +07:00
parent 469d042f4b
commit 7cb6aee3f7
6 changed files with 38 additions and 5 deletions
@@ -68,6 +68,15 @@ export const updateMyMfaEnabled = async (req: Request, res: Response) => {
try {
const { isMfaEnabled }: { isMfaEnabled: boolean } = req.body;
req.user.isMfaEnabled = isMfaEnabled;
if (isMfaEnabled) {
// TODO: adapt this route/controller
// to work for different forms of MFA
req.user.mfaMethods = ['email'];
} else {
req.user.mfaMethods = [];
}
await req.user.save();
user = req.user;
+10 -3
View File
@@ -17,7 +17,8 @@ export interface IUser {
verifier?: string;
refreshVersion?: number;
isMfaEnabled: boolean;
seenIps: [string];
mfaMethods: boolean;
seenIps: [string]; // TODO 1: email for unseen IPs, TODO 2: move to a central alerting system
}
const userSchema = new Schema<IUser>(
@@ -82,8 +83,14 @@ const userSchema = new Schema<IUser>(
type: Boolean,
default: false
},
seenIps: [String]
},
mfaMethods: [{
type: String
}],
seenIps: {
type: [String],
default: []
}
},
{
timestamps: true
}