|
@@ -34,7 +34,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
/**
|
|
|
* 登录校验方法
|
|
|
- *
|
|
|
+ *
|
|
|
* @author ygp
|
|
|
*/
|
|
|
@Component
|
|
@@ -51,19 +51,19 @@ public class SysLoginService
|
|
|
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private ISysUserService userService;
|
|
|
|
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
|
-
|
|
|
+
|
|
|
@Autowired
|
|
|
private IChannelService channelService;
|
|
|
|
|
|
/**
|
|
|
* 登录验证
|
|
|
- *
|
|
|
+ *
|
|
|
* @param username 用户名
|
|
|
* @param password 密码
|
|
|
* @param code 验证码
|
|
@@ -98,9 +98,11 @@ public class SysLoginService
|
|
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
|
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
|
|
recordLoginInfo(loginUser.getUser());
|
|
|
-
|
|
|
- // loginUser.setIdentity(UserIdentityEnum.valueOf(identity));
|
|
|
- fillChannelInfo(loginUser);
|
|
|
+
|
|
|
+ loginUser.setIdentity(UserIdentityEnum.valueOf(identity));
|
|
|
+ if (UserIdentityEnum.isChannel(loginUser.getIdentity())) {
|
|
|
+ fillChannelInfo(loginUser);
|
|
|
+ }
|
|
|
/*
|
|
|
// 根据用户身份,设置对应的属性
|
|
|
loginUser.setIdentity(UserIdentityEnum.valueOf(identity));
|
|
@@ -114,10 +116,10 @@ public class SysLoginService
|
|
|
// 生成token
|
|
|
return tokenService.createToken(loginUser);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 登录验证
|
|
|
- *
|
|
|
+ *
|
|
|
* @param username 用户名
|
|
|
* @param code 验证码
|
|
|
* @param uuid 唯一标识
|
|
@@ -128,7 +130,7 @@ public class SysLoginService
|
|
|
{
|
|
|
// 校验短信验证码
|
|
|
validateSMSCaptcha(username, code, uuid);
|
|
|
-
|
|
|
+
|
|
|
// 用户验证
|
|
|
Authentication authentication = null;
|
|
|
try
|
|
@@ -153,9 +155,11 @@ public class SysLoginService
|
|
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
|
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
|
|
recordLoginInfo(loginUser.getUser());
|
|
|
-
|
|
|
- // loginUser.setIdentity(UserIdentityEnum.valueOf(identity));
|
|
|
- fillChannelInfo(loginUser);
|
|
|
+
|
|
|
+ loginUser.setIdentity(UserIdentityEnum.valueOf(identity));
|
|
|
+ if (UserIdentityEnum.isChannel(loginUser.getIdentity())) {
|
|
|
+ fillChannelInfo(loginUser);
|
|
|
+ }
|
|
|
/*
|
|
|
// 根据用户身份,设置对应的属性
|
|
|
loginUser.setIdentity(UserIdentityEnum.valueOf(identity));
|
|
@@ -198,8 +202,11 @@ public class SysLoginService
|
|
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(smsCode.getMobile(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
|
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
|
|
recordLoginInfo(loginUser.getUser());
|
|
|
-
|
|
|
- fillChannelInfo(loginUser);
|
|
|
+
|
|
|
+ loginUser.setIdentity(UserIdentityEnum.valueOf(smsCode.getIdentity()));
|
|
|
+ if (UserIdentityEnum.isChannel(loginUser.getIdentity())) {
|
|
|
+ fillChannelInfo(loginUser);
|
|
|
+ }
|
|
|
/*
|
|
|
// 根据用户身份,设置对应的属性
|
|
|
loginUser.setIdentity(UserIdentityEnum.valueOf(smsCode.getIdentity()));
|
|
@@ -221,7 +228,7 @@ public class SysLoginService
|
|
|
|
|
|
/**
|
|
|
* 校验验证码
|
|
|
- *
|
|
|
+ *
|
|
|
* @param username 用户名
|
|
|
* @param code 验证码
|
|
|
* @param uuid 唯一标识
|
|
@@ -243,10 +250,10 @@ public class SysLoginService
|
|
|
throw new CaptchaException();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 校验验证码
|
|
|
- *
|
|
|
+ *
|
|
|
* @param username 用户名
|
|
|
* @param code 短信验证码
|
|
|
* @param uuid 唯一标识
|
|
@@ -278,7 +285,7 @@ public class SysLoginService
|
|
|
user.setLoginDate(DateUtils.getNowDate());
|
|
|
userService.updateUserProfile(user);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 填充注入Channel 渠道/经销商 信息
|
|
|
* @param loginUser
|
|
@@ -286,12 +293,15 @@ public class SysLoginService
|
|
|
public void fillChannelInfo(LoginUser loginUser){
|
|
|
Channel channel = channelService.getChannelByUserId(loginUser.getUserId());
|
|
|
if (null != channel && null != channel.getId()){
|
|
|
- loginUser.setChannelId(channel.getId());
|
|
|
- loginUser.setChannelNo(channel.getChannelNo());
|
|
|
- if(null != channel.getLevel()) {
|
|
|
- loginUser.setIdentity(channel.getLevel().intValue() == 0?UserIdentityEnum.SALESITE:UserIdentityEnum.CHANNEL);
|
|
|
- }
|
|
|
- } else if (loginUser.getUserId() != 1L){
|
|
|
+ // 校验渠道身份标识
|
|
|
+ if (loginUser.getIdentity() == UserIdentityEnum.CHANNEL && channel.getLevel() <= 0) {
|
|
|
+ throw new ServiceException("此账号的渠道不存在");
|
|
|
+ } else if (loginUser.getIdentity() == UserIdentityEnum.SALESITE && channel.getLevel() != 0) {
|
|
|
+ throw new ServiceException("此账号的经销商不存在");
|
|
|
+ }
|
|
|
+ loginUser.setChannelId(channel.getId());
|
|
|
+ loginUser.setChannelNo(channel.getChannelNo());
|
|
|
+ } else {
|
|
|
throw new ServiceException("登录账号不存在");
|
|
|
}
|
|
|
|