|
|
@@ -63,7 +63,7 @@ public class H5AuthServiceImpl implements H5AuthService {
|
|
|
return authUrl;
|
|
|
} catch (Exception e) {
|
|
|
log.error("生成授权URL失败", e);
|
|
|
- throw new RuntimeException("生成授权URL失败: " + e.getMessage());
|
|
|
+ throw new RuntimeException(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -144,7 +144,7 @@ public class H5AuthServiceImpl implements H5AuthService {
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
log.error("获取用户信息失败", e);
|
|
|
- throw new Exception("获取用户信息失败: " + e.getMessage());
|
|
|
+ throw new Exception(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -187,11 +187,17 @@ public class H5AuthServiceImpl implements H5AuthService {
|
|
|
User user = userMapper.selectOne(phoneWrapper);
|
|
|
|
|
|
if (user == null) {
|
|
|
- // 新用户注册
|
|
|
- if (StrUtil.isBlank(dto.getNickname())) {
|
|
|
- throw new RuntimeException("昵称不能为空");
|
|
|
+ // 判断是登录还是注册(通过nickname是否为空来判断)
|
|
|
+ boolean isRegister = !StrUtil.isBlank(dto.getNickname());
|
|
|
+
|
|
|
+ if (!isRegister) {
|
|
|
+ // 登录流程:手机号未注册,报错
|
|
|
+ log.warn("登录失败,手机号未注册: {}", phone);
|
|
|
+ throw new RuntimeException("该手机号未注册,请先注册");
|
|
|
}
|
|
|
|
|
|
+ // 注册流程:创建新用户
|
|
|
+ log.info("注册新用户,phone: {}, nickname: {}", phone, dto.getNickname());
|
|
|
user = User.builder()
|
|
|
.openid(dto.getOpenid())
|
|
|
.unionid(dto.getUnionid())
|
|
|
@@ -235,7 +241,7 @@ public class H5AuthServiceImpl implements H5AuthService {
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
log.error("手机号登录失败", e);
|
|
|
- throw new Exception("登录失败: " + e.getMessage());
|
|
|
+ throw new Exception(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
}
|