licailing %!s(int64=5) %!d(string=hai) anos
pai
achega
9aa2204a8f

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