Rewrite continue URL locale after OAuth sign-in

Guests who authenticate from a shared-locale URL were landing
on that URL with a mismatch banner. Adopt Identity.locale on
the OAuth callback redirect instead.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-07-30 15:48:27 +02:00
parent 404b9e347a
commit 1ca9ad439a
3 changed files with 132 additions and 1 deletions

View File

@@ -178,12 +178,23 @@ func (h *OAuthCallbackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
return
}
h.sessionCookie.Set(w, session)
identity, err := h.iam.AccountService.GetIdentity(ctx, identityID)
if err != nil {
h.logger.ErrorCtx(ctx, "cannot load identity", log.Error(err))
httpserver.RenderError(w, http.StatusInternalServerError, errInternal)
return
}
continueURL := state.ContinueURL
if continueURL == "" {
continueURL = "/"
}
if identity.Locale != nil {
continueURL = rewriteContinueURLLocale(continueURL, *identity.Locale)
}
h.sessionCookie.Set(w, session)
h.safeRedirect.Redirect(w, r, continueURL, "/", http.StatusFound)
}