Remove separate Login struct in Page struct

This commit is contained in:
Jan Eitzinger 2022-02-03 09:38:08 +01:00
parent 9766bddb97
commit c98863f22e
2 changed files with 7 additions and 13 deletions

View File

@ -192,9 +192,7 @@ func Login(db *sqlx.DB) http.Handler {
rw.WriteHeader(http.StatusUnauthorized)
templates.Render(rw, r, "login.tmpl", &templates.Page{
Title: "Login failed",
Login: &templates.LoginPage{
Error: "Username or password incorrect",
},
})
return
}
@ -293,9 +291,7 @@ func Auth(next http.Handler) http.Handler {
rw.WriteHeader(http.StatusUnauthorized)
templates.Render(rw, r, "login.tmpl", &templates.Page{
Title: "Authentication failed",
Login: &templates.LoginPage{
Error: "No valid session or JWT provided",
},
})
return
}
@ -351,8 +347,6 @@ func Logout(rw http.ResponseWriter, r *http.Request) {
templates.Render(rw, r, "login.tmpl", &templates.Page{
Title: "Logout successful",
Login: &templates.LoginPage{
Info: "Logout successful",
},
})
}

View File

@ -7,15 +7,15 @@
<div class="container">
<div class="row">
<div class="col-4 mx-auto">
{{if .Login.Error}}
{{if .Error}}
<div class="alert alert-warning" role="alert">
{{.Login.Error}}
{{.Error}}
</div>
{{end}}
{{if .Login.Info}}
{{if .Info}}
<div class="alert alert-success" role="alert">
{{.Login.Info}}
{{.Info}}
</div>
{{end}}