From cd94929e20dce7a9f97698b74ae409fb1a9b52de Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Fri, 26 Dec 2025 22:51:07 +0800 Subject: [PATCH] core: fix oauth callback with mail only (#1110) --- packages/hydrooj/src/handler/user.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/hydrooj/src/handler/user.ts b/packages/hydrooj/src/handler/user.ts index c3d6b7cb6..c96431b55 100644 --- a/packages/hydrooj/src/handler/user.ts +++ b/packages/hydrooj/src/handler/user.ts @@ -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 = '';