chore(auth): #331 add change password tests
All checks were successful
Build and Push Docker Image / Build-And-Push-Docker-Image (push) Successful in 52s

This commit was merged in pull request #354.
This commit is contained in:
2024-12-25 22:17:12 +01:00
committed by Tim Wundenberg
parent 87188724ac
commit 14b477f560
2 changed files with 190 additions and 4 deletions

View File

@@ -45,8 +45,8 @@ func (handler AuthImpl) Handle(router *http.ServeMux) {
router.Handle("/auth/delete-account", handler.handleDeleteAccountPage())
router.Handle("/api/auth/delete-account", handler.handleDeleteAccountComp())
router.Handle("/auth/change-password", handler.handleChangePasswordPage())
router.Handle("/api/auth/change-password", handler.handleChangePasswordComp())
router.Handle("GET /auth/change-password", handler.handleChangePasswordPage())
router.Handle("POST /api/auth/change-password", handler.handleChangePasswordComp())
router.Handle("/auth/forgot-password", handler.handleForgotPasswordPage())
router.Handle("/api/auth/forgot-password", handler.handleForgotPasswordComp())
@@ -307,7 +307,7 @@ func (handler AuthImpl) handleChangePasswordComp() http.HandlerFunc {
session := middleware.GetSession(r)
user := middleware.GetUser(r)
if session == nil || user == nil {
utils.DoRedirect(w, r, "/auth/signin")
utils.TriggerToast(w, r, "error", "Unathorized", http.StatusUnauthorized)
return
}
@@ -316,7 +316,7 @@ func (handler AuthImpl) handleChangePasswordComp() http.HandlerFunc {
err := handler.service.ChangePassword(user, session.Id, currPass, newPass)
if err != nil {
utils.TriggerToast(w, r, "error", "Password not correct", http.StatusUnauthorized)
utils.TriggerToast(w, r, "error", "Password not correct", http.StatusBadRequest)
return
}