mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-07 16:30:49 +00:00
UBERF-6310: Fix context passing (#5167)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
dc7512a844
commit
1664419b7b
@ -6,7 +6,7 @@ import { Strategy as GitHubStrategy } from 'passport-github2'
|
|||||||
import { Passport } from '.'
|
import { Passport } from '.'
|
||||||
|
|
||||||
export function registerGithub (
|
export function registerGithub (
|
||||||
ctx: MeasureContext,
|
measureCtx: MeasureContext,
|
||||||
passport: Passport,
|
passport: Passport,
|
||||||
router: Router<any, any>,
|
router: Router<any, any>,
|
||||||
accountsUrl: string,
|
accountsUrl: string,
|
||||||
@ -45,23 +45,27 @@ export function registerGithub (
|
|||||||
const email = ctx.state.user.emails?.[0]?.value ?? `github:${ctx.state.user.username}`
|
const email = ctx.state.user.emails?.[0]?.value ?? `github:${ctx.state.user.username}`
|
||||||
const [first, last] = ctx.state.user.displayName.split(' ')
|
const [first, last] = ctx.state.user.displayName.split(' ')
|
||||||
if (email !== undefined) {
|
if (email !== undefined) {
|
||||||
if (ctx.query?.state != null) {
|
try {
|
||||||
const loginInfo = await joinWithProvider(ctx, db, productId, email, first, last, ctx.query.state, {
|
if (ctx.query?.state != null) {
|
||||||
githubId: ctx.state.user.id
|
const loginInfo = await joinWithProvider(measureCtx, db, productId, email, first, last, ctx.query.state, {
|
||||||
})
|
githubId: ctx.state.user.id
|
||||||
if (ctx.session != null) {
|
})
|
||||||
ctx.session.loginInfo = loginInfo
|
if (ctx.session != null) {
|
||||||
}
|
ctx.session.loginInfo = loginInfo
|
||||||
} else {
|
}
|
||||||
const loginInfo = await loginWithProvider(ctx, db, productId, email, first, last, {
|
} else {
|
||||||
githubId: ctx.state.user.id
|
const loginInfo = await loginWithProvider(measureCtx, db, productId, email, first, last, {
|
||||||
})
|
githubId: ctx.state.user.id
|
||||||
if (ctx.session != null) {
|
})
|
||||||
ctx.session.loginInfo = loginInfo
|
if (ctx.session != null) {
|
||||||
|
ctx.session.loginInfo = loginInfo
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Successful authentication, redirect to your application
|
||||||
|
ctx.redirect(concatLink(frontUrl, '/login/auth'))
|
||||||
|
} catch (err: any) {
|
||||||
|
await measureCtx.error('failed to auth', err)
|
||||||
}
|
}
|
||||||
// Successful authentication, redirect to your application
|
|
||||||
ctx.redirect(concatLink(frontUrl, '/login/auth'))
|
|
||||||
}
|
}
|
||||||
await next()
|
await next()
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import { Strategy as GoogleStrategy } from 'passport-google-oauth20'
|
|||||||
import { Passport } from '.'
|
import { Passport } from '.'
|
||||||
|
|
||||||
export function registerGoogle (
|
export function registerGoogle (
|
||||||
ctx: MeasureContext,
|
measureCtx: MeasureContext,
|
||||||
passport: Passport,
|
passport: Passport,
|
||||||
router: Router<any, any>,
|
router: Router<any, any>,
|
||||||
accountsUrl: string,
|
accountsUrl: string,
|
||||||
@ -46,19 +46,24 @@ export function registerGoogle (
|
|||||||
const first = ctx.state.user.name.givenName
|
const first = ctx.state.user.name.givenName
|
||||||
const last = ctx.state.user.name.familyName
|
const last = ctx.state.user.name.familyName
|
||||||
if (email !== undefined) {
|
if (email !== undefined) {
|
||||||
if (ctx.query?.state != null) {
|
try {
|
||||||
const loginInfo = await joinWithProvider(ctx, db, productId, email, first, last, ctx.query.state)
|
if (ctx.query?.state != null) {
|
||||||
if (ctx.session != null) {
|
const loginInfo = await joinWithProvider(measureCtx, db, productId, email, first, last, ctx.query.state)
|
||||||
ctx.session.loginInfo = loginInfo
|
if (ctx.session != null) {
|
||||||
}
|
ctx.session.loginInfo = loginInfo
|
||||||
} else {
|
}
|
||||||
const loginInfo = await loginWithProvider(ctx, db, productId, email, first, last)
|
} else {
|
||||||
if (ctx.session != null) {
|
const loginInfo = await loginWithProvider(measureCtx, db, productId, email, first, last)
|
||||||
ctx.session.loginInfo = loginInfo
|
if (ctx.session != null) {
|
||||||
|
ctx.session.loginInfo = loginInfo
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Successful authentication, redirect to your application
|
||||||
|
ctx.redirect(concatLink(frontUrl, '/login/auth'))
|
||||||
|
} catch (err: any) {
|
||||||
|
await measureCtx.error('failed to auth', err)
|
||||||
}
|
}
|
||||||
// Successful authentication, redirect to your application
|
|
||||||
ctx.redirect(concatLink(frontUrl, '/login/auth'))
|
|
||||||
}
|
}
|
||||||
await next()
|
await next()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user