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