mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-24 01:07:50 +00:00
Fix github oauth (#5729)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
0afcc2cdfe
commit
4a229eb671
@ -42,10 +42,10 @@ export function registerGithub (
|
|||||||
redirectURL,
|
redirectURL,
|
||||||
passport.authenticate('github', { failureRedirect: concatLink(frontUrl, '/login'), session: true }),
|
passport.authenticate('github', { failureRedirect: concatLink(frontUrl, '/login'), session: true }),
|
||||||
async (ctx, next) => {
|
async (ctx, next) => {
|
||||||
const email = ctx.state.user.emails?.[0]?.value ?? `github:${ctx.state.user.username}`
|
|
||||||
const [first, last] = ctx.state.user.displayName.split(' ')
|
|
||||||
if (email !== undefined) {
|
|
||||||
try {
|
try {
|
||||||
|
const email = ctx.state.user.emails?.[0]?.value ?? `github:${ctx.state.user.username}`
|
||||||
|
const [first, last] = ctx.state.user.displayName?.split(' ') ?? [ctx.state.user.username, '']
|
||||||
|
if (email !== undefined) {
|
||||||
if (ctx.query?.state != null) {
|
if (ctx.query?.state != null) {
|
||||||
const loginInfo = await joinWithProvider(
|
const loginInfo = await joinWithProvider(
|
||||||
measureCtx,
|
measureCtx,
|
||||||
@ -73,10 +73,10 @@ export function registerGithub (
|
|||||||
}
|
}
|
||||||
// Successful authentication, redirect to your application
|
// Successful authentication, redirect to your application
|
||||||
ctx.redirect(concatLink(frontUrl, '/login/auth'))
|
ctx.redirect(concatLink(frontUrl, '/login/auth'))
|
||||||
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
measureCtx.error('failed to auth', err)
|
measureCtx.error('failed to auth', err)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
await next()
|
await next()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user