From bf57b2ad1362e2ea619c3a23aba337e6ac54e738 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 14 Apr 2018 06:41:33 +0900 Subject: [PATCH] Fix bug --- src/server/api/service/twitter.ts | 34 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/server/api/service/twitter.ts b/src/server/api/service/twitter.ts index 0de2e68c60..284ae7ee22 100644 --- a/src/server/api/service/twitter.ts +++ b/src/server/api/service/twitter.ts @@ -118,21 +118,27 @@ if (config.twitter == null) { return; } - redis.get(sessid, async (_, twCtx) => { - const result = await twAuth.done(JSON.parse(twCtx), ctx.query.oauth_verifier); - - const user = await User.findOne({ - host: null, - 'twitter.userId': result.userId - }) as ILocalUser; - - if (user == null) { - ctx.throw(404, `@${result.screenName}と連携しているMisskeyアカウントはありませんでした...`); - return; - } - - signin(ctx, user, true); + const get = new Promise((res, rej) => { + redis.get(sessid, async (_, twCtx) => { + res(twCtx); + }); }); + + const twCtx = await get; + + const result = await twAuth.done(JSON.parse(twCtx), ctx.query.oauth_verifier); + + const user = await User.findOne({ + host: null, + 'twitter.userId': result.userId + }) as ILocalUser; + + if (user == null) { + ctx.throw(404, `@${result.screenName}と連携しているMisskeyアカウントはありませんでした...`); + return; + } + + signin(ctx, user, true); } else { const verifier = ctx.query.oauth_verifier;