mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: 优化注册逻辑以防止在token失效时丢出系统级错误
This commit is contained in:
1 parent
ba94c59e3f
commit
c3b314f8dd
4 files changed
+5
-8
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.15.13",
|
||||
"version": "2.15.14",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -158,7 +158,7 @@ class HomeSecurityHandler extends Handler {
|
||||
if (udoc) throw new UserAlreadyExistError(email);
|
||||
const [code] = await token.add(
|
||||
token.TYPE_CHANGEMAIL,
|
||||
system.get('changemail_token_expire_seconds'),
|
||||
system.get('session.unsaved_expire_seconds'),
|
||||
{ uid: this.user._id, email },
|
||||
);
|
||||
const m = await this.renderHTML('user_changemail_mail.html', {
|
||||
|
||||
@@ -97,10 +97,10 @@ class UserRegisterWithCodeHandler extends Handler {
|
||||
domainId: string, password: string, verify: string,
|
||||
uname: string, code: string,
|
||||
) {
|
||||
const { mail } = await token.get(code, token.TYPE_REGISTRATION);
|
||||
if (!mail) throw new InvalidTokenError(token.TYPE_REGISTRATION, code);
|
||||
const tdoc = await token.get(code, token.TYPE_REGISTRATION);
|
||||
if (!tdoc || !tdoc.mail) throw new InvalidTokenError(token.TYPE_REGISTRATION, code);
|
||||
if (password !== verify) throw new VerifyPasswordError();
|
||||
const uid = await user.create(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);
|
||||
this.session.uid = uid;
|
||||
this.session.scpoe = PERM.PERM_ALL;
|
||||
|
||||
@@ -36,9 +36,6 @@ export interface SystemKeys {
|
||||
'session.secure': boolean,
|
||||
'session.expire_seconds': number,
|
||||
'session.unsaved_expire_seconds': number,
|
||||
'lostpass_token_expire_seconds': number,
|
||||
'registration_token_expire_seconds': number,
|
||||
'changemail_token_expire_seconds': number,
|
||||
'user.quota': number,
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user