ui: fix login by email

This commit is contained in:
undefined committed 2023-01-24 17:16:28 +08:00
1 parent 78be1d6fc5
commit 4b74ebbeba
3 files changed
+12 -8

No files matched your search

+2 -2
View File
@@ -4,7 +4,7 @@ import crypto from 'crypto';
import esbuild from 'esbuild'; import esbuild from 'esbuild';
import { import {
ContestModel, Context, fs, Handler, Logger, ObjectID, param, PERM, PRIV, ProblemModel, Schema, ContestModel, Context, fs, Handler, Logger, ObjectID, param, PERM, PRIV, ProblemModel, Schema,
SettingModel, SystemModel, SystemSettings, Types, UiContextBase, UserModel, SettingModel, size, SystemModel, SystemSettings, Types, UiContextBase, UserModel,
} from 'hydrooj'; } from 'hydrooj';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { tmpdir } from 'os'; import { tmpdir } from 'os';
@@ -79,7 +79,7 @@ export async function buildUI() {
const version = c.digest('hex'); const version = c.digest('hex');
constant = JSON.stringify(payload); constant = JSON.stringify(payload);
UiContextBase.constantVersion = hash = version; UiContextBase.constantVersion = hash = version;
logger.success('UI addons built in %d ms', Date.now() - start); logger.success('UI addons built in %d ms (%s)', Date.now() - start, size(constant.length));
} }
function updateLogo() { function updateLogo() {
UiContextBase.nav_logo_dark = SystemModel.get('ui-default.nav_logo_dark'); UiContextBase.nav_logo_dark = SystemModel.get('ui-default.nav_logo_dark');
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/ui-default", "name": "@hydrooj/ui-default",
"version": "4.46.0", "version": "4.46.1",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "index.ts", "main": "index.ts",
@@ -74,12 +74,16 @@ export default new AutoloadPage('user_verify', () => {
ev.preventDefault(); ev.preventDefault();
const $form = ev.currentTarget.form; const $form = ev.currentTarget.form;
const uname = $('[name="uname"]').val() as string; const uname = $('[name="uname"]').val() as string;
const { tfa, authn } = await api(gql` const info = await api(gql`
user(uname:${uname}){ uname: user(uname:${uname}){
tfa tfa authn
authn
} }
`, ['data', 'user']); mail: user(mail:${uname}){
tfa authn
}
`, ['data']);
if (!info.uname && !info.mail) Notification.error(i18n('User not found.'));
const { authn, tfa } = info.uname || info.mail;
if (authn || tfa) { if (authn || tfa) {
let action = (authn && tfa) ? await chooseAction(true) : ''; let action = (authn && tfa) ? await chooseAction(true) : '';
if (!action) action = tfa ? await chooseAction(false) : 'webauthn'; if (!action) action = tfa ? await chooseAction(false) : 'webauthn';