From 70361d12d8c36f7dde33008b3c6ebe50e056b4f2 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Fri, 1 Mar 2024 12:16:32 +0600 Subject: [PATCH] Fix oauth session (#4840) Signed-off-by: Denis Bykhov --- pods/authProviders/src/index.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pods/authProviders/src/index.ts b/pods/authProviders/src/index.ts index dc6d760d34..f8f821b66f 100644 --- a/pods/authProviders/src/index.ts +++ b/pods/authProviders/src/index.ts @@ -1,11 +1,10 @@ import Koa from 'koa' import passport from 'koa-passport' import Router from 'koa-router' -import { Db } from 'mongodb' -import { registerGoogle } from './google' import session from 'koa-session' -import { concatLink } from '@hcengineering/core' +import { Db } from 'mongodb' import { registerGithub } from './github' +import { registerGoogle } from './google' export type Passport = typeof passport @@ -38,7 +37,14 @@ export function registerProviders ( } app.keys = [serverSecret] - app.use(session({}, app)) + app.use( + session( + { + domain: accountsUrl.split('.', 2)[1] + }, + app + ) + ) app.use(passport.initialize()) app.use(passport.session()) @@ -64,10 +70,8 @@ export function registerProviders ( router.get('auth', '/auth', (ctx) => { if (ctx.session?.loginInfo != null) { - ctx.body = JSON.stringify(ctx.session?.loginInfo) - return + ctx.body = JSON.stringify(ctx.session.loginInfo) } - ctx.redirect(concatLink(frontUrl, '/login')) }) router.get('providers', '/providers', (ctx) => {