From 91172654e4b715198099146d4c442e0787df0785 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 13 Feb 2021 15:33:38 +0900 Subject: refactor: resolve #7139 --- src/server/api/service/github.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/server/api/service/github.ts') diff --git a/src/server/api/service/github.ts b/src/server/api/service/github.ts index 663c3cc754..2b10fa02a0 100644 --- a/src/server/api/service/github.ts +++ b/src/server/api/service/github.ts @@ -10,7 +10,6 @@ import signin from '../common/signin'; import { fetchMeta } from '../../../misc/fetch-meta'; import { Users, UserProfiles } from '../../../models'; import { ILocalUser } from '../../../models/entities/user'; -import { ensure } from '../../../prelude/ensure'; function getUserToken(ctx: Koa.Context) { return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1]; @@ -41,12 +40,12 @@ router.get('/disconnect/github', async ctx => { return; } - const user = await Users.findOne({ + const user = await Users.findOneOrFail({ host: null, token: userToken - }).then(ensure); + }); - const profile = await UserProfiles.findOne(user.id).then(ensure); + const profile = await UserProfiles.findOneOrFail(user.id); delete profile.integrations.github; @@ -227,12 +226,12 @@ router.get('/gh/cb', async ctx => { return; } - const user = await Users.findOne({ + const user = await Users.findOneOrFail({ host: null, token: userToken - }).then(ensure); + }); - const profile = await UserProfiles.findOne(user.id).then(ensure); + const profile = await UserProfiles.findOneOrFail(user.id); await UserProfiles.update(user.id, { integrations: { -- cgit v1.2.3-freya