|
|
@@ -65,19 +65,21 @@ public class UserService {
|
|
|
if (StrUtil.isNotBlank(password)) {
|
|
|
user.setPassword(new BCryptPasswordEncoder().encode(password));
|
|
|
}
|
|
|
- userRepo.save(user);
|
|
|
- } else {
|
|
|
- if (user.getBlacklist()) {
|
|
|
- throw new BusinessException("被拉入黑名单!");
|
|
|
- }
|
|
|
- if (RIDER.equals(identity)) {
|
|
|
- boolean matches = new BCryptPasswordEncoder().matches(password, user.getPassword());
|
|
|
- if (!matches) {
|
|
|
- throw new BusinessException("密码不正确");
|
|
|
- }
|
|
|
+ return userRepo.save(user);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public User merUser(MerchantDTO merchantDTO) {
|
|
|
@@ -102,20 +104,20 @@ public class UserService {
|
|
|
return userRepo.save(user);
|
|
|
}
|
|
|
|
|
|
- public User loginByPhone(String phone, String code) {
|
|
|
+ public User loginByPhone(String phone, String code, Identity identity) {
|
|
|
try {
|
|
|
smsService.verify(phone, code);
|
|
|
} catch (SmsService.SmsVerifyException e) {
|
|
|
e.printStackTrace();
|
|
|
throw new BusinessException("验证码错误");
|
|
|
}
|
|
|
- User user = userRepo.findByPhone(phone);
|
|
|
+ User user = userRepo.findByPhoneAndIdentity(phone, identity);
|
|
|
if (user == null) {
|
|
|
user = User.builder()
|
|
|
.username(UUID.randomUUID().toString())
|
|
|
.nickname(phone)
|
|
|
.phone(phone)
|
|
|
- .identity(USER)
|
|
|
+ .identity(identity)
|
|
|
.enabled(true)
|
|
|
.avatar(Constants.DEFAULT_AVATAR)
|
|
|
.build();
|