Factoring the model user and correcting password

This commit is contained in:
Chris Mann 2023-07-22 07:53:21 +02:00
parent bcba1417f3
commit 7fca2fa4ae

View file

@ -205,16 +205,21 @@ func handleLogin(w http.ResponseWriter, r *http.Request) *LoginInfo {
templateLogin.Execute(w, LoginFormData{}) templateLogin.Execute(w, LoginFormData{})
return nil return nil
} else if r.Method == "POST" { } else if r.Method == "POST" {
log.Printf("%v", "Parsing Form handleLogin")
r.ParseForm() r.ParseForm()
username := strings.Join(r.Form["username"], "") username := strings.Join(r.Form["username"], "")
password := strings.Join(r.Form["password"], "") password := strings.Join(r.Form["password"], "")
user_dn := fmt.Sprintf("%s=%s,%s", config.UserNameAttr, username, config.UserBaseDN) user_dn := fmt.Sprintf("%s=%s,%s", config.UserNameAttr, username, config.UserBaseDN)
log.Printf("%v", user_dn)
log.Printf("%v", username)
if strings.EqualFold(username, config.AdminAccount) { if strings.EqualFold(username, config.AdminAccount) {
user_dn = username user_dn = username
} }
loginInfo, err := doLogin(w, r, username, user_dn, password) loginInfo, err := doLogin(w, r, username, user_dn, password)
log.Printf("%v", loginInfo)
if err != nil { if err != nil {
data := &LoginFormData{ data := &LoginFormData{
Username: username, Username: username,