chore(auth): #331 add tests for delete account
This commit was merged in pull request #343.
This commit is contained in:
@@ -262,7 +262,7 @@ func (handler AuthImpl) handleDeleteAccountComp() http.HandlerFunc {
|
||||
err := handler.service.DeleteAccount(user, password)
|
||||
if err != nil {
|
||||
if err == service.ErrInvalidCredentials {
|
||||
utils.TriggerToast(w, r, "error", "Password not correct", http.StatusUnauthorized)
|
||||
utils.TriggerToast(w, r, "error", "Password not correct", http.StatusBadRequest)
|
||||
} else {
|
||||
utils.TriggerToast(w, r, "error", "Internal Server Error", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ func CrossSiteRequestForgery(auth service.Auth) func(http.Handler) http.Handler
|
||||
if csrfToken == "" {
|
||||
csrfToken = r.Header.Get("csrf-token")
|
||||
}
|
||||
if csrfToken == "" || !auth.IsCsrfTokenValid(csrfToken, session.Id) {
|
||||
http.Error(w, "", http.StatusForbidden)
|
||||
if session == nil || csrfToken == "" || !auth.IsCsrfTokenValid(csrfToken, session.Id) {
|
||||
http.Error(w, "CSRF-Token not correct", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user