連携ログインができないのなどを修正 (#6162)
* 連携ログインができないのを修正 * Cookie名変更, セッションに * igiはやっぱり非セッションCookieで * 2回目以降Discordログインできなくなるのを修正
This commit is contained in:
parent
1b48e0d6e0
commit
80eedf7449
7 changed files with 28 additions and 38 deletions
|
|
@ -12,7 +12,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) {
|
||||
|
|
@ -102,14 +102,10 @@ router.get('/signin/twitter', async ctx => {
|
|||
|
||||
redis.set(sessid, JSON.stringify(twCtx));
|
||||
|
||||
const expires = 1000 * 60 * 60; // 1h
|
||||
ctx.cookies.set('signin_with_twitter_session_id', sessid, {
|
||||
ctx.cookies.set('signin_with_twitter_sid', sessid, {
|
||||
path: '/',
|
||||
domain: config.host,
|
||||
secure: config.url.startsWith('https'),
|
||||
httpOnly: true,
|
||||
expires: new Date(Date.now() + expires),
|
||||
maxAge: expires
|
||||
httpOnly: true
|
||||
});
|
||||
|
||||
ctx.redirect(twCtx.url);
|
||||
|
|
@ -121,7 +117,7 @@ router.get('/tw/cb', async ctx => {
|
|||
const twAuth = await getTwAuth();
|
||||
|
||||
if (userToken == null) {
|
||||
const sessid = ctx.cookies.get('signin_with_twitter_session_id');
|
||||
const sessid = ctx.cookies.get('signin_with_twitter_sid');
|
||||
|
||||
if (sessid == null) {
|
||||
ctx.throw(400, 'invalid session');
|
||||
|
|
@ -139,7 +135,7 @@ router.get('/tw/cb', async ctx => {
|
|||
const result = await twAuth!.done(JSON.parse(twCtx), ctx.query.oauth_verifier);
|
||||
|
||||
const link = await UserProfiles.createQueryBuilder()
|
||||
.where('"integrations"->"twitter"->"userId" = :id', { id: result.userId })
|
||||
.where(`"integrations"->'twitter'->>'userId' = :id`, { id: result.userId })
|
||||
.andWhere('"userHost" IS NULL')
|
||||
.getOne();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue