Set correct login flow
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Melora Hugues 2023-10-15 20:11:50 +02:00
parent 20fde2335e
commit 1e8b9ef161
9 changed files with 34 additions and 43 deletions

View file

@ -35,8 +35,14 @@ func NewIndexController(l *logrus.Logger, downstream http.Handler) *IndexControl
}
func (ic IndexController) serveUI(w http.ResponseWriter, r *http.Request) (int, int, error) {
funcs := template.FuncMap{
"issuer": func() string { return "toto" },
}
lp := filepath.Join("templates", "index.html")
tmpl, err := template.ParseFiles(lp)
hdrTpl := filepath.Join("templates", "header.html")
footTpl := filepath.Join("templates", "footer.html")
tmpl, err := template.New("index.html").Funcs(funcs).ParseFiles(hdrTpl, footTpl, lp)
if err != nil {
return http.StatusInternalServerError, -1, fmt.Errorf("failed to init template: %w", err)
}
@ -55,14 +61,13 @@ func (ic IndexController) serveUI(w http.ResponseWriter, r *http.Request) (int,
func (ic *IndexController) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.RequestURI != "/" {
ic.l.Debugf("Serving URI %q to dex handler", r.RequestURI)
ic.downstreamConstroller.ServeHTTP(w, r)
return
}
returncode, contentLength, err := ic.serveUI(w, r)
returncode, _, err := ic.serveUI(w, r)
if err != nil {
ic.l.Errorf("Error serving UI: %s", err.Error())
helpers.HandleResponse(w, r, returncode, nil, ic.l)
} else {
helpers.AddToContext(r, returncode, contentLength)
}
}