diff --git a/authentication.go b/authentication.go index e018182..6af204a 100644 --- a/authentication.go +++ b/authentication.go @@ -83,7 +83,7 @@ func loginHandler(response http.ResponseWriter, request *http.Request) { func resetPasswordHandler(response http.ResponseWriter, request *http.Request) { name := request.FormValue("email") pass := request.FormValue("password") - redirectTarget := "/" + redirectTarget := "/wait_for_password_confirmation.html" logit(fmt.Sprintf("resetPasswordHandler: request for User %s", name)) if name != "" && pass != "" { if checkUserAvailable(name) { @@ -122,6 +122,9 @@ func logoutHandler(response http.ResponseWriter, request *http.Request) { func confirmHandler(response http.ResponseWriter, request *http.Request) { confirm_id := request.URL.Query().Get("id") logit(fmt.Sprintf("Confirm ID: %s\n", confirm_id)) - confirmUser(confirm_id) - http.Redirect(response, request, "/", 302) + if confirmUser(confirm_id) { + http.Redirect(response, request, "/password_changed.html", 302) + } else { + http.Redirect(response, request, "/", 302) + } } diff --git a/persistence.go b/persistence.go index 8f9247a..889e68b 100644 --- a/persistence.go +++ b/persistence.go @@ -361,28 +361,30 @@ func updateLoginTime(username string) { } } -func confirmUser(confirm_id string) { +func confirmUser(confirm_id string) bool { conn := globalPool.Get() defer conn.Close() u, err := redis.String(conn.Do("GET", confirmPrefix+confirm_id)) if err != nil { logit("confirmUser: Error with searching confirm_id: " + confirm_id) - return + return false } new_password, err := redis.String(conn.Do("HGET", userPrefix+u, "new_password")) if err != nil { logit("confirmUser: Error with getting new_password: " + u) - return + return false } _, err = conn.Do("HMSET", userPrefix+u, "confirm_id", "", "password", new_password) if err != nil { logit("confirmUser: Error updateing User: " + u) - return + return false } _, err = conn.Do("DEL", confirmPrefix+confirm_id) if err != nil { logit("confirmUser: Error deleting confirm_id: " + confirm_id) - return + return false } + + return true } diff --git a/snippets/password_changed.html b/snippets/password_changed.html new file mode 100644 index 0000000..88a7c99 --- /dev/null +++ b/snippets/password_changed.html @@ -0,0 +1,9 @@ +{{define "body_content"}} +{{ if ne .UserName "" }} +Sie sind bereits eingeloggt! +{{ else }} +
+Passwort wurde erfolgreich geändert! +
+{{ end }} +{{end}} diff --git a/snippets/wait_for_password_confirmation.html b/snippets/wait_for_password_confirmation.html new file mode 100644 index 0000000..5ddfaed --- /dev/null +++ b/snippets/wait_for_password_confirmation.html @@ -0,0 +1,10 @@ +{{define "body_content"}} +{{ if ne .UserName "" }} +Sie sind bereits eingeloggt! +{{ else }} +

Passwort zurücksetzen - warte auf Bestätigung

+
+

Bitte checken Sie Ihre Mailbox. Das neue Passwort wird erst gültig, wenn Sie die Bestätigung durchgeführt haben.

+
+{{end}} +{{end}}