chore(auth): #331 add change password tests
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user