Change status and password method #3

Merged
lqhoang99 merged 3 commits from feature/changeStatus-password into master 2021-11-09 04:03:28 +00:00
lqhoang99 commented 2021-11-09 02:39:40 +00:00 (Migrated from github.com)
No description provided.
namhq1989 (Migrated from github.com) reviewed 2021-11-09 02:46:11 +00:00
@ -48,10 +54,71 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error {
}
namhq1989 (Migrated from github.com) commented 2021-11-09 02:46:11 +00:00

ChangePasswordByUserID -> ChangeUserPassword

ChangePasswordByUserID -> ChangeUserPassword
namhq1989 (Migrated from github.com) reviewed 2021-11-09 02:49:33 +00:00
namhq1989 (Migrated from github.com) left a comment

check

check
@ -48,10 +54,71 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error {
}
namhq1989 (Migrated from github.com) commented 2021-11-09 02:47:10 +00:00

đưa ra validate:

  • user id -> valid mongo id
  • old password != ""
  • new password != ""
đưa ra validate: - user id -> valid mongo id - old password != "" - new password != ""
namhq1989 (Migrated from github.com) commented 2021-11-09 02:47:26 +00:00

old or new password cannot be empty

old or new password cannot be empty
namhq1989 (Migrated from github.com) commented 2021-11-09 02:47:42 +00:00

user not found

user not found
namhq1989 (Migrated from github.com) commented 2021-11-09 02:48:21 +00:00
if isValid := checkPasswordHash(oldPassword, user.HashedPassword); !isValid {
  return errors.New("the password is incorrect")
}
```go if isValid := checkPasswordHash(oldPassword, user.HashedPassword); !isValid { return errors.New("the password is incorrect") } ```
namhq1989 (Migrated from github.com) commented 2021-11-09 02:48:54 +00:00

ChangeUserStatus

  • func này check thêm nếu user.Status == newStatus thì return luôn ko cần làm gì nữa
ChangeUserStatus - func này check thêm nếu `user.Status == newStatus` thì return luôn ko cần làm gì nữa
namhq1989 (Migrated from github.com) commented 2021-11-09 02:49:16 +00:00

mọi id client gửi qua đều phải validate lại

mọi id client gửi qua đều phải validate lại
lqhoang99 (Migrated from github.com) reviewed 2021-11-09 03:22:59 +00:00
@ -48,10 +54,71 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error {
}
lqhoang99 (Migrated from github.com) commented 2021-11-09 03:22:59 +00:00

done

done
lqhoang99 (Migrated from github.com) reviewed 2021-11-09 03:23:03 +00:00
@ -48,10 +54,71 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error {
}
lqhoang99 (Migrated from github.com) commented 2021-11-09 03:23:03 +00:00

done

done
lqhoang99 (Migrated from github.com) reviewed 2021-11-09 03:23:08 +00:00
@ -48,10 +54,71 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error {
}
lqhoang99 (Migrated from github.com) commented 2021-11-09 03:23:08 +00:00

done

done
lqhoang99 (Migrated from github.com) reviewed 2021-11-09 03:23:12 +00:00
@ -48,10 +54,71 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error {
}
lqhoang99 (Migrated from github.com) commented 2021-11-09 03:23:12 +00:00

done

done
lqhoang99 (Migrated from github.com) reviewed 2021-11-09 03:23:16 +00:00
@ -48,10 +54,71 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error {
}
lqhoang99 (Migrated from github.com) commented 2021-11-09 03:23:16 +00:00

done

done
lqhoang99 (Migrated from github.com) reviewed 2021-11-09 03:23:20 +00:00
@ -48,10 +54,71 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error {
}
lqhoang99 (Migrated from github.com) commented 2021-11-09 03:23:19 +00:00

done

done
lqhoang99 (Migrated from github.com) reviewed 2021-11-09 03:23:28 +00:00
@ -48,10 +54,71 @@ func (s Service) UpdateByUserID(userID string, payload UpdateOptions) error {
}
lqhoang99 (Migrated from github.com) commented 2021-11-09 03:23:28 +00:00

done

done
namhq1989 (Migrated from github.com) reviewed 2021-11-09 03:42:24 +00:00
@ -52,0 +58,4 @@
return err
}
return nil
namhq1989 (Migrated from github.com) commented 2021-11-09 03:42:23 +00:00

cái này cũng move về dạng if như trên đi

if a := ...; a {
  // ...
}

chú ý mấy cái khác tương tự luôn, đưa về cách trên cho gọn code

cái này cũng move về dạng if như trên đi ```go if a := ...; a { // ... } ``` chú ý mấy cái khác tương tự luôn, đưa về cách trên cho gọn code
lqhoang99 (Migrated from github.com) reviewed 2021-11-09 03:54:33 +00:00
@ -52,0 +58,4 @@
return err
}
return nil
lqhoang99 (Migrated from github.com) commented 2021-11-09 03:54:32 +00:00

done

done
namhq1989 (Migrated from github.com) reviewed 2021-11-09 03:56:59 +00:00
namhq1989 (Migrated from github.com) left a comment

check

check
@ -52,0 +58,4 @@
return err
}
return nil
namhq1989 (Migrated from github.com) commented 2021-11-09 03:42:50 +00:00

fix như trên

fix như trên
@ -56,0 +107,4 @@
// Validate userID
id, isValid := mongodb.NewIDFromString(userID)
if !isValid {
return errors.New("invalid user id data")
namhq1989 (Migrated from github.com) commented 2021-11-09 03:56:42 +00:00

chỗ này cũng check được như trên nè

chỗ này cũng check được như trên nè
Sign in to join this conversation.
No description provided.