release- 登录校验用户状态

release-2024-08-08
huangyawei 6 months ago
parent 1d958a3edd
commit 2808ef350a

@ -50,4 +50,6 @@ public class ErrorConstants {
public final static String AMOUNT_MUST_BE_GREATER_THAN_0 = "金额必须大于0"; public final static String AMOUNT_MUST_BE_GREATER_THAN_0 = "金额必须大于0";
public final static String USER_ALREADY_EXISTS_ARTIST = "用户已发起过音乐人审核"; public final static String USER_ALREADY_EXISTS_ARTIST = "用户已发起过音乐人审核";
public final static String USER_STATUS_ERROR = "用户状态错误";
} }

@ -12,6 +12,10 @@ import com.alibaba.fastjson.JSONObject;
import com.luoo.user.dto.request.*; import com.luoo.user.dto.request.*;
import com.luoo.user.service.WeChatAouth2Service; import com.luoo.user.service.WeChatAouth2Service;
import com.luoo.user.util.IOSTokenUtils; import com.luoo.user.util.IOSTokenUtils;
import constants.ErrorConstants;
import enums.UserStatusEnum;
import exception.BizException;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
@ -372,6 +376,10 @@ public class LoginController extends BaseController {
@PostMapping("/login/{userName}/{password}") @PostMapping("/login/{userName}/{password}")
public Result loginByUserName(@PathVariable String userName, @PathVariable String password) { public Result loginByUserName(@PathVariable String userName, @PathVariable String password) {
UserInfo userInfo = userInfoService.findByUserNameAndPassword(userName, password); UserInfo userInfo = userInfoService.findByUserNameAndPassword(userName, password);
if(ObjectUtils.notEqual(UserStatusEnum.ENABLE.getStatus(), userInfo.getStatus())){
// 用户状态错误
throw new BizException(ErrorConstants.USER_STATUS_ERROR);
}
if (userInfo !=null) { if (userInfo !=null) {
//生成token //生成token
String token = jwtUtil.createJWT(userInfo.getId(),userInfo.getUserName(),"artist",""); String token = jwtUtil.createJWT(userInfo.getId(),userInfo.getUserName(),"artist","");

Loading…
Cancel
Save