From d19476d7e7a7fb991b9d56fb1f5ceb41f46900e6 Mon Sep 17 00:00:00 2001 From: undefined Date: Sun, 10 Apr 2022 19:51:02 +0800 Subject: [PATCH] core: handle oauth redirect --- packages/hydrooj/package.json | 2 +- packages/hydrooj/src/handler/user.ts | 1 + packages/login-with-github/lib.ts | 1 - packages/login-with-github/package.json | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index f8643258b..801cbfe58 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "3.11.15", + "version": "3.11.16", "bin": "bin/hydrooj.js", "main": "src/loader", "module": "src/loader", diff --git a/packages/hydrooj/src/handler/user.ts b/packages/hydrooj/src/handler/user.ts index d16142972..c55459ef4 100644 --- a/packages/hydrooj/src/handler/user.ts +++ b/packages/hydrooj/src/handler/user.ts @@ -410,6 +410,7 @@ class OauthCallbackHandler extends Handler { this.session.uid = _id; this.session.scope = PERM.PERM_ALL.toString(); } + this.response.redirect = '/'; } } diff --git a/packages/login-with-github/lib.ts b/packages/login-with-github/lib.ts index 6994c9356..47ad41646 100644 --- a/packages/login-with-github/lib.ts +++ b/packages/login-with-github/lib.ts @@ -72,7 +72,6 @@ async function callback({ state, code }) { } await token.del(s._id, token.TYPE_OAUTH); if (!ret.email) throw new ForbiddenError("You don't have a verified email."); - this.response.redirect = (s.redirect || '').endsWith('/login') ? '/' : s.redirect; return ret; } diff --git a/packages/login-with-github/package.json b/packages/login-with-github/package.json index 334bd6b5b..2e5bbcca4 100644 --- a/packages/login-with-github/package.json +++ b/packages/login-with-github/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/login-with-github", - "version": "0.1.5", + "version": "0.1.6", "main": "package.json", "repository": "git@github.com:hydro-dev/Hydro.git", "author": "undefined ",