-
Notifications
You must be signed in to change notification settings - Fork 28
/
authflow_reauth.go
41 lines (33 loc) · 1.2 KB
/
authflow_reauth.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package webapp
import (
"net/http"
"github.com/authgear/authgear-server/pkg/auth/webapp"
authflow "github.com/authgear/authgear-server/pkg/lib/authenticationflow"
"github.com/authgear/authgear-server/pkg/util/httproute"
)
func ConfigureAuthflowReauthRoute(route httproute.Route) httproute.Route {
return route.
WithMethods("OPTIONS", "GET").
WithPathPattern(webapp.AuthflowRouteReauth)
}
type AuthflowReauthHandler struct {
Controller *AuthflowController
AuthflowNavigator AuthflowNavigator
}
func (h *AuthflowReauthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
opts := webapp.SessionOptions{
RedirectURI: h.Controller.RedirectURI(r),
}
var handlers AuthflowControllerHandlers
handlers.Get(func(s *webapp.Session, screen *webapp.AuthflowScreenWithFlowResponse) error {
// HandleStartOfFlow used to redirect to the next screen for us.
// But that redirect was removed.
// So we need to redirect here.
// See https://github.com/authgear/authgear-server/issues/3470
result := &webapp.Result{}
screen.Navigate(h.AuthflowNavigator, r, s.ID, result)
result.WriteResponse(w, r)
return nil
})
h.Controller.HandleStartOfFlow(w, r, opts, authflow.FlowTypeReauth, &handlers, nil)
}