summaryrefslogtreecommitdiff
path: root/src/server/api/service/discord.ts
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2020-03-20 13:56:22 +0900
committerGitHub <noreply@github.com>2020-03-20 13:56:22 +0900
commit80eedf744944769c8ba9bbdccc2aa7dad06b2151 (patch)
tree41914408b985d41e526259bfb2e118502221f2f1 /src/server/api/service/discord.ts
parentRevert "Update dependencies (#6167)" (#6168) (diff)
downloadmisskey-80eedf744944769c8ba9bbdccc2aa7dad06b2151.tar.gz
misskey-80eedf744944769c8ba9bbdccc2aa7dad06b2151.tar.bz2
misskey-80eedf744944769c8ba9bbdccc2aa7dad06b2151.zip
連携ログインができないのなどを修正 (#6162)
* 連携ログインができないのを修正 * Cookie名変更, セッションに * igiはやっぱり非セッションCookieで * 2回目以降Discordログインできなくなるのを修正
Diffstat (limited to 'src/server/api/service/discord.ts')
-rw-r--r--src/server/api/service/discord.ts15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/server/api/service/discord.ts b/src/server/api/service/discord.ts
index f9f3026aa8..c2bb02453b 100644
--- a/src/server/api/service/discord.ts
+++ b/src/server/api/service/discord.ts
@@ -13,7 +13,7 @@ import { ILocalUser } from '../../../models/entities/user';
import { ensure } from '../../../prelude/ensure';
function getUserToken(ctx: Koa.Context) {
- return ((ctx.headers['cookie'] || '').match(/i=(\w+)/) || [null, null])[1];
+ return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
}
function compareOrigin(ctx: Koa.Context) {
@@ -113,14 +113,10 @@ router.get('/signin/discord', async ctx => {
response_type: 'code'
};
- const expires = 1000 * 60 * 60; // 1h
- ctx.cookies.set('signin_with_discord_session_id', sessid, {
+ ctx.cookies.set('signin_with_discord_sid', sessid, {
path: '/',
- domain: config.host,
secure: config.url.startsWith('https'),
- httpOnly: true,
- expires: new Date(Date.now() + expires),
- maxAge: expires
+ httpOnly: true
});
redis.set(sessid, JSON.stringify(params));
@@ -135,7 +131,7 @@ router.get('/dc/cb', async ctx => {
const oauth2 = await getOAuth2();
if (!userToken) {
- const sessid = ctx.cookies.get('signin_with_discord_session_id');
+ const sessid = ctx.cookies.get('signin_with_discord_sid');
if (!sessid) {
ctx.throw(400, 'invalid session');
@@ -199,7 +195,7 @@ router.get('/dc/cb', async ctx => {
}
const profile = await UserProfiles.createQueryBuilder()
- .where('"integrations"->"discord"->"id" = :id', { id: id })
+ .where(`"integrations"->'discord'->>'id' = :id`, { id: id })
.andWhere('"userHost" IS NULL')
.getOne();
@@ -212,6 +208,7 @@ router.get('/dc/cb', async ctx => {
integrations: {
...profile.integrations,
discord: {
+ id: id,
accessToken: accessToken,
refreshToken: refreshToken,
expiresDate: expiresDate,