Skip to content

Commit

Permalink
fix: use correct redirection for registration
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Aug 26, 2020
1 parent c5f361f commit 8d47113
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions selfservice/strategy/password/registration.go
Expand Up @@ -16,7 +16,7 @@ import (

"github.com/ory/kratos/driver/configuration"
"github.com/ory/kratos/selfservice/flow"
"github.com/ory/kratos/selfservice/flow/settings"
"github.com/ory/kratos/session"

"github.com/ory/herodot"
"github.com/ory/x/urlx"
Expand All @@ -40,7 +40,14 @@ type RegistrationFormPayload struct {

func (s *Strategy) RegisterRegistrationRoutes(public *x.RouterPublic) {
s.d.CSRFHandler().ExemptPath(RouteRegistration)
public.POST(RouteRegistration, s.d.SessionHandler().IsNotAuthenticated(s.handleRegistration, settings.OnUnauthenticated(s.c, s.d)))
public.POST(RouteRegistration, s.d.SessionHandler().IsNotAuthenticated(s.handleRegistration, func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
handler := session.RedirectOnAuthenticated(s.c)
if x.IsJSONRequest(r) {
handler = session.RespondWithJSONErrorOnAuthenticated(s.d.Writer(), registration.ErrAlreadyLoggedIn)
}

handler(w, r, ps)
}))
}

func (s *Strategy) handleRegistrationError(w http.ResponseWriter, r *http.Request, rr *registration.Flow, p *RegistrationFormPayload, err error) {
Expand Down

0 comments on commit 8d47113

Please sign in to comment.