licailing 5 vuotta sitten
vanhempi
commit
9aa2204a8f
1 muutettua tiedostoa jossa 8 lisäystä ja 2 poistoa
  1. 8 2
      src/main/java/com/izouma/dingdong/service/UserService.java

+ 8 - 2
src/main/java/com/izouma/dingdong/service/UserService.java

@@ -50,9 +50,9 @@ public class UserService {
     public User register(String phone, String password, Identity identity) {
         User user = userRepo.findByPhoneAndIdentity(phone, identity);
         if (ObjectUtil.isNull(user)) {
-            if (RIDER.equals(identity)) {
+/*            if (RIDER.equals(identity)) {
                 throw new BusinessException("未注册");
-            }
+            }*/
             user = User.builder()
                     .username(phone)
                     .nickname(user.getDefaultUsername(phone))
@@ -72,6 +72,12 @@ public class UserService {
             if (user.getBlacklist()) {
                 throw new BusinessException("被拉入黑名单!");
             }
+            if (RIDER.equals(identity)) {
+                boolean matches = new BCryptPasswordEncoder().matches(password, user.getPassword());
+                if (!matches) {
+                    throw new BusinessException("密码不正确");
+                }
+            }
         }
         return user;
     }