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:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user