Fixed Change Password Bug

This commit is contained in:
Chris Mann 2023-07-24 15:57:01 +02:00
parent 65d63bc49d
commit ca571fa687

View file

@ -26,11 +26,26 @@ type ProfileTplData struct {
//ProfilePicture string //ProfilePicture string
//Visibility string //Visibility string
type PasswdTplData struct {
Status *LoginStatus
ErrorMessage string
TooShortError bool
NoMatchError bool
Success bool
CanAdmin bool
Login bool
}
func handleProfile(w http.ResponseWriter, r *http.Request) { func handleProfile(w http.ResponseWriter, r *http.Request) {
templateProfile := getTemplate("profile.html") templateProfile := getTemplate("profile.html")
login := checkLogin(w, r) login := checkLogin(w, r)
if login == nil { if login == nil {
templatePasswd := getTemplate("passwd.html")
templatePasswd.Execute(w, PasswdTplData{
Login: false,
CanAdmin: false,
})
return return
} }
@ -123,16 +138,6 @@ func handleProfile(w http.ResponseWriter, r *http.Request) {
templateProfile.Execute(w, data) templateProfile.Execute(w, data)
} }
type PasswdTplData struct {
Status *LoginStatus
ErrorMessage string
TooShortError bool
NoMatchError bool
Success bool
CanAdmin bool
Login bool
}
func handleFoundPassword(w http.ResponseWriter, r *http.Request) { func handleFoundPassword(w http.ResponseWriter, r *http.Request) {
templateFoundPasswordPage := getTemplate("passwd.html") templateFoundPasswordPage := getTemplate("passwd.html")
data := PasswdTplData{ data := PasswdTplData{
@ -187,20 +192,20 @@ func handleFoundPassword(w http.ResponseWriter, r *http.Request) {
func handlePasswd(w http.ResponseWriter, r *http.Request) { func handlePasswd(w http.ResponseWriter, r *http.Request) {
templatePasswd := getTemplate("passwd.html") templatePasswd := getTemplate("passwd.html")
login := checkLogin(w, r)
if login == nil {
return
}
data := &PasswdTplData{ data := &PasswdTplData{
Status: login,
ErrorMessage: "", ErrorMessage: "",
Success: false, Success: false,
CanAdmin: false, CanAdmin: false,
Login: false, Login: false,
} }
login := checkLogin(w, r)
if login == nil {
templatePasswd.Execute(w, data)
return
}
data.Status = login
if r.Method == "POST" { if r.Method == "POST" {
r.ParseForm() r.ParseForm()