Fix redirects on /sign_in when -skip-provider-button is set
Push the logic down a level: now the dispatch happens in SignInPage, where the correct redirect URI is known. Fixes #30, hopefully
This commit is contained in:
parent
0af18d6d7c
commit
faf49ee4e3
@ -389,10 +389,9 @@ func (p *OAuthProxy) ErrorPage(rw http.ResponseWriter, code int, title string, m
|
||||
p.templates.ExecuteTemplate(rw, "error.html", t)
|
||||
}
|
||||
|
||||
// SignInPage writes the sing in template to the response
|
||||
// SignInPage writes the sign-in template to the response
|
||||
func (p *OAuthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code int) {
|
||||
p.ClearSessionCookie(rw, req)
|
||||
rw.WriteHeader(code)
|
||||
|
||||
redirecURL := req.URL.RequestURI()
|
||||
if req.Header.Get("X-Auth-Request-Redirect") != "" {
|
||||
@ -402,6 +401,14 @@ func (p *OAuthProxy) SignInPage(rw http.ResponseWriter, req *http.Request, code
|
||||
redirecURL = "/"
|
||||
}
|
||||
|
||||
if p.SkipProviderButton {
|
||||
req.Form.Set("rd", redirecURL)
|
||||
p.OAuthStart(rw, req)
|
||||
return
|
||||
}
|
||||
|
||||
rw.WriteHeader(code)
|
||||
|
||||
t := struct {
|
||||
ProviderName string
|
||||
SignInMessage string
|
||||
@ -542,13 +549,9 @@ func (p *OAuthProxy) SignIn(rw http.ResponseWriter, req *http.Request) {
|
||||
session := &sessionsapi.SessionState{User: user}
|
||||
p.SaveSession(rw, req, session)
|
||||
http.Redirect(rw, req, redirect, 302)
|
||||
} else {
|
||||
if p.SkipProviderButton {
|
||||
p.OAuthStart(rw, req)
|
||||
} else {
|
||||
p.SignInPage(rw, req, http.StatusOK)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SignOut sends a response to clear the authentication cookie
|
||||
|
Loading…
Reference in New Issue
Block a user