|
|
|
@ -31,6 +31,7 @@ import org.springframework.security.core.Authentication;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 登录校验方法
|
|
|
|
@ -73,7 +74,7 @@ public class SysLoginService {
|
|
|
|
|
* @param uuid 唯一标识
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
public String login(String username, String password, String code, String uuid) {
|
|
|
|
|
public Map<String, Object> login(String username, String password, String code, String uuid, String userType) {
|
|
|
|
|
// 验证码校验
|
|
|
|
|
validateCaptcha(username, code, uuid);
|
|
|
|
|
// 登录前置校验
|
|
|
|
@ -98,7 +99,29 @@ public class SysLoginService {
|
|
|
|
|
}
|
|
|
|
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
|
|
|
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
|
|
|
|
recordLoginInfo(loginUser.getUserId());
|
|
|
|
|
// recordLoginInfo(loginUser.getUserId());
|
|
|
|
|
if (StringUtils.isNull(loginUser) || StringUtils.isNull(loginUser.getUserId())) {
|
|
|
|
|
addRecord(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
|
|
|
|
throw new ServiceException("登录用户:" + username + " 不存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysUser user = loginUser.getUser();
|
|
|
|
|
// 判断用户类型
|
|
|
|
|
if (!"admin".equals(username)) {
|
|
|
|
|
if (!userType.equals(user.getUserType())) {
|
|
|
|
|
throw new ServiceException("该用户类型错误");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
|
|
|
|
addRecord(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
|
|
|
|
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
|
|
|
|
}
|
|
|
|
|
if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
|
|
|
|
addRecord(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
|
|
|
|
|
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
|
|
|
|
|
}
|
|
|
|
|
// sysPasswordService.validate(user);
|
|
|
|
|
|
|
|
|
|
// 生成token
|
|
|
|
|
return tokenService.createToken(loginUser);
|
|
|
|
|