mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17: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
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user