Restructuring the Project
Updating dependencies
This commit is contained in:
16
Backend/src/api/user/twofactor/helper.ts
Normal file
16
Backend/src/api/user/twofactor/helper.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import LoginToken, { ILoginToken } from "../../../models/login_token";
|
||||
import moment = require("moment");
|
||||
|
||||
export async function upgradeToken(token: ILoginToken) {
|
||||
token.data = undefined;
|
||||
token.valid = true;
|
||||
token.validated = true;
|
||||
//TODO durations from config
|
||||
let expires = (token.special
|
||||
? moment().add(30, "minute")
|
||||
: moment().add(6, "months")
|
||||
).toDate();
|
||||
token.validTill = expires;
|
||||
await LoginToken.save(token);
|
||||
return expires;
|
||||
}
|
Reference in New Issue
Block a user