[go: nahoru, domu]

Skip to content

Commit

Permalink
uberf-7350: add more oauth logs (hcengineering#5879)
Browse files Browse the repository at this point in the history
  • Loading branch information
lexiv0re committed Jun 21, 2024
1 parent 182d108 commit adb2866
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pods/authProviders/src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions pods/authProviders/src/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit adb2866

Please sign in to comment.