Skip to content

Commit 55384cf

Browse files
authored
Merge pull request #12 from ockibagusp/session-3-Is-types
fix update user by password: delete IsAdmin and IsUser
2 parents 64f0948 + 7eb21f3 commit 55384cf

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ $ go test github.com/ockibagusp/golang-website-example/tests -v
107107
108108
109109
## TODO List
110-
- Table database Users to testing: admin, user and no-auth
111110
- Admin Users: delete table User `deleted_at` @route: /users/admin/delete
112111
113112
button:

controllers/user_controller.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,9 @@ func (controller *Controller) UpdateUserByPassword(c echo.Context) error {
532532
ConfirmNewPassword: c.FormValue("confirm_new_password"),
533533
}
534534

535-
// TODO: middleware.CheckHashPassword?
536-
if (middleware.IsAdmin(is_auth_type) && middleware.IsUser(is_auth_type)) && middleware.CheckHashPassword(user.Password, _newPasswordForm.OldPassword) {
535+
if !middleware.CheckHashPassword(user.Password, _newPasswordForm.OldPassword) {
537536
log.Warnf(
538-
"for POST to update user by password without IsAdmin and IsUser (%v) and check hash password (%v): 403 Forbidden",
539-
middleware.IsAdmin(is_auth_type) && middleware.IsUser(is_auth_type),
537+
"for POST to update user by password without check hash password (%v): 403 Forbidden",
540538
middleware.CheckHashPassword(user.Password, _newPasswordForm.OldPassword),
541539
)
542540
middleware.SetFlashError(c, "check hash password is wrong!")

0 commit comments

Comments
 (0)