core: 2fa support

This commit is contained in:
undefined committed 2021-11-12 22:23:06 +08:00
1 parent f18547ba16
commit fe1112e652
11 files changed
+200 -6

No files matched your search

+4
View File
@@ -53,6 +53,7 @@ class User implements _User {
_hash: string;
_regip: string;
_loginip: string;
_tfa: string;
mail: string;
uname: string;
@@ -64,6 +65,7 @@ class User implements _User {
role: string;
scope: bigint;
_files: FileInfo[];
tfa: boolean;
[key: string]: any;
constructor(udoc: Udoc, dudoc, scope = PERM.PERM_ALL) {
@@ -76,6 +78,7 @@ class User implements _User {
this._regip = udoc.ip?.[0] || '';
this._loginip = udoc.loginip;
this._files = udoc._files || [];
this._tfa = udoc.tfa;
this.mail = udoc.mail;
this.uname = udoc.uname;
@@ -86,6 +89,7 @@ class User implements _User {
this.perm = dudoc.perm;
this.scope = typeof scope === 'string' ? BigInt(scope) : scope;
this.role = dudoc.role || 'default';
this.tfa = !!udoc.tfa;
for (const key in setting.SETTINGS_BY_KEY) {
this[key] = udoc[key] ?? setting.SETTINGS_BY_KEY[key].value;