This commit is contained in:
Chris Mann 2023-07-23 08:39:44 +02:00
parent 12d96166b5
commit ac5aa4eb7e

View file

@ -39,6 +39,8 @@ func checkInviterLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
// New account creation directly from interface
type LostPasswordData struct {
ErrorMessage string
Success bool
Username string
Mail string
OtherMailbox string
@ -46,19 +48,21 @@ type LostPasswordData struct {
func handleLostPassword(w http.ResponseWriter, r *http.Request) {
templateLostPasswordPage := getTemplate("lost_password.html")
l, err := ldapOpen(w)
if err != nil {
log.Printf(fmt.Sprintf("handleLostPassword : %v %v", err, l))
}
err = l.Bind(config.NewUserDN, config.NewUserPassword)
if err != nil {
log.Printf(fmt.Sprintf("handleLostPassword : %v %v", err, l))
}
data := LostPasswordData{
Username: "",
Mail: "",
OtherMailbox: "",
}
l, err := ldapOpen(w)
if err != nil {
log.Printf(fmt.Sprintf("handleLostPassword : %v %v", err, l))
data.ErrorMessage = err.Error()
}
err = l.Bind(config.NewUserDN, config.NewUserPassword)
if err != nil {
log.Printf(fmt.Sprintf("handleLostPassword : %v %v", err, l))
data.ErrorMessage = err.Error()
}
if r.Method == "POST" {
r.ParseForm()
data.Username = strings.TrimSpace(strings.Join(r.Form["username"], ""))
@ -73,6 +77,9 @@ func handleLostPassword(w http.ResponseWriter, r *http.Request) {
err = l.Bind(config.NewUserDN, config.NewUserPassword)
if err != nil {
log.Printf(fmt.Sprintf("handleLostPassword : %v %v", err, l))
data.ErrorMessage = err.Error()
} else {
data.Success = true
}
}
templateLostPasswordPage.Execute(w, data)