mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
Fix oauth session (#4840)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
2e028e913e
commit
70361d12d8
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user