summaryrefslogtreecommitdiff
path: root/src/server/api/service/github.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2021-02-13 15:33:38 +0900
committersyuilo <syuilotan@yahoo.co.jp>2021-02-13 15:33:38 +0900
commit91172654e4b715198099146d4c442e0787df0785 (patch)
treed6cc5de1c3be9e143c76c05fffe7d2f07fc376c8 /src/server/api/service/github.ts
parentwip: email notification (diff)
downloadsharkey-91172654e4b715198099146d4c442e0787df0785.tar.gz
sharkey-91172654e4b715198099146d4c442e0787df0785.tar.bz2
sharkey-91172654e4b715198099146d4c442e0787df0785.zip
refactor: resolve #7139
Diffstat (limited to 'src/server/api/service/github.ts')
-rw-r--r--src/server/api/service/github.ts13
1 files changed, 6 insertions, 7 deletions
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: {