core: fix oauth callback with mail only (#1110)

This commit is contained in:
Baoshuo authored and GitHub committed 2025-12-26 22:51:07 +08:00
1 parent f2b79e3ba1
commit cd94929e20
1 file changed
+8 -1
+8 -1
View File
@@ -476,12 +476,19 @@ class OauthCallbackHandler extends Handler {
return;
}
const uid = await this.ctx.oauth.get(args.type, r._id) || await this.ctx.oauth.get('mail', r.email);
const uid = await this.ctx.oauth.get(args.type, r._id);
if (uid) {
await successfulAuth.call(this, await user.getById('system', uid));
this.response.redirect = '/';
return;
}
const udoc = await user.getByEmail('system', r.email);
if (udoc) {
await this.ctx.oauth.set(args.type, r._id, udoc._id);
await successfulAuth.call(this, udoc);
this.response.redirect = '/';
return;
}
if (!provider.canRegister) throw new ForbiddenError('No binded account found');
this.checkPriv(PRIV.PRIV_REGISTER_USER);
let username = '';