Fixed Change Password Bug

This commit is contained in:
Chris Mann 2023-07-25 15:14:12 +02:00
parent 9a3f234f9b
commit 25035d684d
2 changed files with 9 additions and 6 deletions

View file

@ -19,9 +19,12 @@ func handleHome(w http.ResponseWriter, r *http.Request) {
login := checkLogin(w, r) login := checkLogin(w, r)
if login == nil { if login == nil {
handleLogin(w, r) status := handleLogin(w, r)
if status == nil {
return return
} }
login = checkLogin(w, r)
}
data := HomePageData{ data := HomePageData{
Login: login, Login: login,

View file

@ -61,10 +61,7 @@ type LoginFormData struct {
func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo { func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
templateLogin := getTemplate("login.html") templateLogin := getTemplate("login.html")
if r.Method == "GET" { if r.Method == "POST" {
templateLogin.Execute(w, LoginFormData{CanAdmin: false})
return nil
} else if r.Method == "POST" {
// log.Printf("%v", "Parsing Form handleLogin") // log.Printf("%v", "Parsing Form handleLogin")
r.ParseForm() r.ParseForm()
@ -100,6 +97,9 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
} }
return loginInfo return loginInfo
} else if r.Method == "GET" {
templateLogin.Execute(w, LoginFormData{CanAdmin: false})
return nil
} else { } else {
http.Error(w, "Unsupported method", http.StatusBadRequest) http.Error(w, "Unsupported method", http.StatusBadRequest)
return nil return nil