mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-14 02:37:25 +01:00
Fix beeing logged out
This commit is contained in:
parent
0c074e8c29
commit
319cdfd069
14
server.go
14
server.go
@ -363,15 +363,21 @@ func main() {
|
|||||||
http.RedirectHandler("/", http.StatusTemporaryRedirect),
|
http.RedirectHandler("/", http.StatusTemporaryRedirect),
|
||||||
|
|
||||||
// On failure:
|
// On failure:
|
||||||
func(rw http.ResponseWriter, r *http.Request, loginErr error) {
|
func(rw http.ResponseWriter, r *http.Request, err error) {
|
||||||
rw.WriteHeader(http.StatusUnauthorized)
|
rw.WriteHeader(http.StatusUnauthorized)
|
||||||
templates.Render(rw, r, "login.tmpl", &templates.Page{
|
templates.Render(rw, r, "login.tmpl", &templates.Page{
|
||||||
Title: "Login failed - ClusterCockpit",
|
Title: "Login failed - ClusterCockpit",
|
||||||
Error: loginErr.Error(),
|
Error: err.Error(),
|
||||||
})
|
})
|
||||||
})).Methods(http.MethodPost)
|
})).Methods(http.MethodPost)
|
||||||
|
|
||||||
r.Handle("/logout", authentication.Logout(http.RedirectHandler("/login", http.StatusTemporaryRedirect))).Methods(http.MethodPost)
|
r.Handle("/logout", authentication.Logout(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||||
|
rw.WriteHeader(http.StatusOK)
|
||||||
|
templates.Render(rw, r, "login.tmpl", &templates.Page{
|
||||||
|
Title: "Bye - ClusterCockpit",
|
||||||
|
Info: "Logout sucessful",
|
||||||
|
})
|
||||||
|
}))).Methods(http.MethodPost)
|
||||||
|
|
||||||
secured.Use(func(next http.Handler) http.Handler {
|
secured.Use(func(next http.Handler) http.Handler {
|
||||||
return authentication.Auth(
|
return authentication.Auth(
|
||||||
@ -379,7 +385,7 @@ func main() {
|
|||||||
next,
|
next,
|
||||||
|
|
||||||
// On failure:
|
// On failure:
|
||||||
func(rw http.ResponseWriter, r *http.Request, authErr error) {
|
func(rw http.ResponseWriter, r *http.Request, err error) {
|
||||||
rw.WriteHeader(http.StatusUnauthorized)
|
rw.WriteHeader(http.StatusUnauthorized)
|
||||||
templates.Render(rw, r, "login.tmpl", &templates.Page{
|
templates.Render(rw, r, "login.tmpl", &templates.Page{
|
||||||
Title: "Authentication failed - ClusterCockpit",
|
Title: "Authentication failed - ClusterCockpit",
|
||||||
|
Loading…
Reference in New Issue
Block a user