Fix oauth session (#4840)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2024-03-01 12:16:32 +06:00 committed by GitHub
parent 2e028e913e
commit 70361d12d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) => {