mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix change language
This commit is contained in:
1 parent
5b9601f8c3
commit
b776155993
4 files changed
+9
-4
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.39.8",
|
"version": "2.39.9",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -253,6 +253,7 @@ class HomeSettingsHandler extends Handler {
|
|||||||
}
|
}
|
||||||
for (const key in booleanKeys) if (!args[key]) $set[key] = false;
|
for (const key in booleanKeys) if (!args[key]) $set[key] = false;
|
||||||
await setter($set);
|
await setter($set);
|
||||||
|
if (args.viewLang && args.viewLang !== this.session.viewLang) this.session.viewLang = '';
|
||||||
this.back();
|
this.back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ class UserLoginHandler extends Handler {
|
|||||||
udoc.checkPassword(password);
|
udoc.checkPassword(password);
|
||||||
await user.setById(udoc._id, { loginat: new Date(), loginip: this.request.ip });
|
await user.setById(udoc._id, { loginat: new Date(), loginip: this.request.ip });
|
||||||
if (!udoc.hasPriv(PRIV.PRIV_USER_PROFILE)) throw new BlacklistedError(uname);
|
if (!udoc.hasPriv(PRIV.PRIV_USER_PROFILE)) throw new BlacklistedError(uname);
|
||||||
|
this.session.viewLang = '';
|
||||||
this.session.uid = udoc._id;
|
this.session.uid = udoc._id;
|
||||||
this.session.scope = PERM.PERM_ALL.toString();
|
this.session.scope = PERM.PERM_ALL.toString();
|
||||||
this.session.save = rememberme;
|
this.session.save = rememberme;
|
||||||
@@ -175,7 +176,11 @@ class UserRegisterWithCodeHandler extends Handler {
|
|||||||
const uid = await user.create(tdoc.mail, uname, password, undefined, this.request.ip);
|
const uid = await user.create(tdoc.mail, uname, password, undefined, this.request.ip);
|
||||||
await token.del(code, token.TYPE_REGISTRATION);
|
await token.del(code, token.TYPE_REGISTRATION);
|
||||||
const [id, domain] = tdoc.mail.split('@');
|
const [id, domain] = tdoc.mail.split('@');
|
||||||
if (domain === 'qq.com' && !Number.isNaN(+id)) await user.setById(uid, { avatar: `qq:${id}` });
|
const $set: any = {};
|
||||||
|
if (domain === 'qq.com' && !Number.isNaN(+id)) $set.avatar = `qq:${id}`;
|
||||||
|
if (this.session.viewLang) $set.viewLang = this.session.viewLang;
|
||||||
|
if (Object.keys($set).length) await user.setById(uid, $set);
|
||||||
|
this.session.viewLang = '';
|
||||||
this.session.uid = uid;
|
this.session.uid = uid;
|
||||||
this.session.scpoe = PERM.PERM_ALL.toString();
|
this.session.scpoe = PERM.PERM_ALL.toString();
|
||||||
this.response.redirect = this.url('home_settings', { category: 'preference' });
|
this.response.redirect = this.url('home_settings', { category: 'preference' });
|
||||||
|
|||||||
@@ -527,8 +527,7 @@ export class Handler extends HandlerCommon {
|
|||||||
this.session.scope = PERM.PERM_ALL.toString();
|
this.session.scope = PERM.PERM_ALL.toString();
|
||||||
this.user = await user.getById(domainId, this.session.uid, this.session.scope);
|
this.user = await user.getById(domainId, this.session.uid, this.session.scope);
|
||||||
}
|
}
|
||||||
if (this.user._id !== 0 && this.session.viewLang) this.user.viewLang = this.session.viewLang;
|
if (this.user._id === 0) delete this.user.viewLang;
|
||||||
else if (this.user._id === 0) delete this.user.viewLang;
|
|
||||||
this.user.avatarUrl = avatar(this.user.avatar, 128);
|
this.user.avatarUrl = avatar(this.user.avatar, 128);
|
||||||
this.csrfToken = this.getCsrfToken(this.session._id || String.random(32));
|
this.csrfToken = this.getCsrfToken(this.session._id || String.random(32));
|
||||||
this.UiContext.csrfToken = this.csrfToken;
|
this.UiContext.csrfToken = this.csrfToken;
|
||||||
|
|||||||
Reference in new issue
Block a user