core: 优化注册逻辑以防止在token失效时丢出系统级错误

This commit is contained in:
undefined committed 2021-01-08 22:04:25 +08:00
1 parent ba94c59e3f
commit c3b314f8dd
4 files changed
+5 -8

No files matched your search

+3 -3
View File
@@ -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;