feat: display login succeeded page only for native apps (#2839)

This commit is contained in:
Livio Amstutz
2021-12-14 09:47:49 +01:00
committed by GitHub
parent 2265fffd8e
commit 79f7c1198b
6 changed files with 112 additions and 19 deletions

View File

@@ -21,8 +21,11 @@ func (l *Login) redirectToLoginSuccess(w http.ResponseWriter, r *http.Request, i
func (l *Login) handleLoginSuccess(w http.ResponseWriter, r *http.Request) {
authRequest, _ := l.getAuthRequest(r)
if authRequest != nil {
if !(len(authRequest.PossibleSteps) == 1 && authRequest.PossibleSteps[0].Type() == domain.NextStepRedirectToCallback) {
if authRequest == nil {
l.renderSuccessAndCallback(w, r, nil, nil)
}
for _, step := range authRequest.PossibleSteps {
if step.Type() != domain.NextStepLoginSucceeded && step.Type() != domain.NextStepRedirectToCallback {
l.renderNextStep(w, r, authRequest)
return
}
@@ -43,3 +46,8 @@ func (l *Login) renderSuccessAndCallback(w http.ResponseWriter, r *http.Request,
}
l.renderer.RenderTemplate(w, r, l.getTranslator(authReq), l.renderer.Templates[tmplLoginSuccess], data, nil)
}
func (l *Login) redirectToCallback(w http.ResponseWriter, r *http.Request, authReq *domain.AuthRequest) {
callback := l.oidcAuthCallbackURL + authReq.ID
http.Redirect(w, r, callback, http.StatusFound)
}

View File

@@ -278,6 +278,8 @@ func (l *Login) chooseNextStep(w http.ResponseWriter, r *http.Request, authReq *
l.chooseNextStep(w, r, authReq, 1, err)
return
}
l.redirectToCallback(w, r, authReq)
case *domain.LoginSucceededStep:
l.redirectToLoginSuccess(w, r, authReq.ID)
case *domain.ChangePasswordStep:
l.renderChangePassword(w, r, authReq, err)