Skip to content

Commit cd94929

Browse files
authored
core: fix oauth callback with mail only (#1110)
1 parent f2b79e3 commit cd94929

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • packages/hydrooj/src/handler

packages/hydrooj/src/handler/user.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,12 +476,19 @@ class OauthCallbackHandler extends Handler {
476476
return;
477477
}
478478

479-
const uid = await this.ctx.oauth.get(args.type, r._id) || await this.ctx.oauth.get('mail', r.email);
479+
const uid = await this.ctx.oauth.get(args.type, r._id);
480480
if (uid) {
481481
await successfulAuth.call(this, await user.getById('system', uid));
482482
this.response.redirect = '/';
483483
return;
484484
}
485+
const udoc = await user.getByEmail('system', r.email);
486+
if (udoc) {
487+
await this.ctx.oauth.set(args.type, r._id, udoc._id);
488+
await successfulAuth.call(this, udoc);
489+
this.response.redirect = '/';
490+
return;
491+
}
485492
if (!provider.canRegister) throw new ForbiddenError('No binded account found');
486493
this.checkPriv(PRIV.PRIV_REGISTER_USER);
487494
let username = '';

0 commit comments

Comments
 (0)