feat(login): 非正常账户不可登录
This commit is contained in:
@@ -34,6 +34,7 @@ public enum ResponseEnum {
|
||||
PWD_NOT_SAME(3602, "新密码与原密码不相同"),
|
||||
LOGIN_EXPIRED(3700, "登陆过期"),
|
||||
LOGOUT(3710, "账户已注销"),
|
||||
CAN_NOT_USE(3711, "账户不可用"),
|
||||
PWD_WRONG(3800, "密码不正确"),
|
||||
|
||||
JWT_EXPIRED(3810, "Token过期"),
|
||||
|
||||
@@ -22,6 +22,12 @@ public class MyException extends RuntimeException {
|
||||
this.code = e.getCode();
|
||||
}
|
||||
|
||||
public MyException(ResponseEnum e, Object result) {
|
||||
super(e.getMsg());
|
||||
this.code = e.getCode();
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public MyException(ResponseEnum e, String msg) {
|
||||
super(msg + e.getMsg());
|
||||
this.code = e.getCode();
|
||||
|
||||
@@ -2,6 +2,7 @@ package cn.celess.blog.service.serviceimpl;
|
||||
|
||||
import cn.celess.blog.enmu.ResponseEnum;
|
||||
import cn.celess.blog.enmu.RoleEnum;
|
||||
import cn.celess.blog.enmu.UserAccountStatusEnum;
|
||||
import cn.celess.blog.entity.Response;
|
||||
import cn.celess.blog.entity.User;
|
||||
import cn.celess.blog.entity.model.PageData;
|
||||
@@ -99,6 +100,12 @@ public class UserServiceImpl implements UserService {
|
||||
if (!RegexUtil.pwdMatch(loginReq.getPassword())) {
|
||||
throw new MyException(ResponseEnum.PARAMETERS_PWD_ERROR);
|
||||
}
|
||||
|
||||
User user = userMapper.findByEmail(loginReq.getEmail());
|
||||
if (user.getStatus() != UserAccountStatusEnum.NORMAL.getCode()) {
|
||||
throw new MyException(ResponseEnum.CAN_NOT_USE, UserAccountStatusEnum.get(user.getStatus()));
|
||||
}
|
||||
|
||||
//获取redis缓存中登录失败次数
|
||||
String s = redisUtil.get(loginReq.getEmail() + "-passwordWrongTime");
|
||||
if (s != null) {
|
||||
@@ -106,8 +113,7 @@ public class UserServiceImpl implements UserService {
|
||||
throw new MyException(ResponseEnum.LOGIN_LATER, loginReq.getEmail());
|
||||
}
|
||||
}
|
||||
User user = null;
|
||||
user = userMapper.findByEmail(loginReq.getEmail());
|
||||
|
||||
String token = null;
|
||||
// 密码比对
|
||||
if (user == null) {
|
||||
|
||||
Reference in New Issue
Block a user