uberf-7350: add more oauth logs (#5879)

This commit is contained in:
Alexey Zinoviev 2024-06-21 06:13:31 +04:00 committed by GitHub
parent 182d108b87
commit adb286676e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -38,7 +38,7 @@ export function registerGithub (
router.get('/auth/github', async (ctx, next) => {
measureCtx.info('try auth via', { provider: 'github' })
const host = getHost(ctx.request.headers)
const branding = host !== undefined ? brandings[host]?.key ?? '' : ''
const branding = host !== undefined ? brandings[host]?.key ?? undefined : undefined
const state = encodeURIComponent(
JSON.stringify({
inviteId: ctx.query?.inviteId,

View File

@ -38,7 +38,7 @@ export function registerGoogle (
router.get('/auth/google', async (ctx, next) => {
measureCtx.info('try auth via', { provider: 'google' })
const host = getHost(ctx.request.headers)
const branding = host !== undefined ? brandings[host]?.key ?? '' : ''
const branding = host !== undefined ? brandings[host]?.key ?? undefined : undefined
const state = encodeURIComponent(
JSON.stringify({
inviteId: ctx.query?.inviteId,
@ -53,14 +53,19 @@ export function registerGoogle (
redirectURL,
async (ctx, next) => {
const state = safeParseAuthState(ctx.query?.state)
measureCtx.info('Auth state', { state })
const branding = getBranding(brandings, state?.branding)
measureCtx.info('With branding', { branding })
const failureRedirect = concatLink(branding?.front ?? frontUrl, '/login')
measureCtx.info('With failure redirect', { failureRedirect })
passport.authenticate('google', {
failureRedirect: concatLink(branding?.front ?? frontUrl, '/login'),
failureRedirect,
session: true
})(ctx, next)
},
async (ctx, next) => {
measureCtx.info('Provider auth success', { type: 'google', user: ctx.state?.user })
const email = ctx.state.user.emails?.[0]?.value
const first = ctx.state.user.name.givenName
const last = ctx.state.user.name.familyName