|
@@ -194,6 +194,82 @@ public class AuthServiceImpl implements AuthService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public String doLoginScreen(AuthAccountPasswordLoginParam authAccountPasswordLoginParam, String type) {
|
|
|
+ // 判断账号是否被封禁
|
|
|
+ isDisableTime(authAccountPasswordLoginParam.getAccount());
|
|
|
+ // 获取账号
|
|
|
+ String account = authAccountPasswordLoginParam.getAccount();
|
|
|
+ // 获取密码
|
|
|
+ String password = authAccountPasswordLoginParam.getPassword();
|
|
|
+ // 获取设备
|
|
|
+ String device = authAccountPasswordLoginParam.getDevice();
|
|
|
+ // 默认指定为PC,如在小程序跟移动端的情况下,自行指定即可
|
|
|
+ if(ObjectUtil.isEmpty(device)) {
|
|
|
+ device = AuthDeviceTypeEnum.PC.getValue();
|
|
|
+ } else {
|
|
|
+ AuthDeviceTypeEnum.validate(device);
|
|
|
+ }
|
|
|
+ // 校验验证码
|
|
|
+ String defaultCaptchaOpen = devConfigApi.getValueByKey(SNOWY_SYS_DEFAULT_CAPTCHA_OPEN_KEY);
|
|
|
+ if(ObjectUtil.isNotEmpty(defaultCaptchaOpen)) {
|
|
|
+ if(Convert.toBool(defaultCaptchaOpen)) {
|
|
|
+ // 获取验证码
|
|
|
+ String validCode = authAccountPasswordLoginParam.getValidCode();
|
|
|
+ // 获取验证码请求号
|
|
|
+ String validCodeReqNo = authAccountPasswordLoginParam.getValidCodeReqNo();
|
|
|
+ // 开启验证码则必须传入验证码
|
|
|
+ if(ObjectUtil.isEmpty(validCode)) {
|
|
|
+ throw new CommonException(AuthExceptionEnum.VALID_CODE_EMPTY.getValue());
|
|
|
+ }
|
|
|
+ // 开启验证码则必须传入验证码请求号
|
|
|
+ if(ObjectUtil.isEmpty(validCodeReqNo)) {
|
|
|
+ throw new CommonException(AuthExceptionEnum.VALID_CODE_REQ_NO_EMPTY.getValue());
|
|
|
+ }
|
|
|
+ // 执行校验验证码
|
|
|
+ validValidCode(null, validCode, validCodeReqNo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // SM2解密并获得前端传来的密码哈希值
|
|
|
+ String passwordHash="";
|
|
|
+ try {
|
|
|
+ // 解密,并做哈希值
|
|
|
+// passwordHash="207cf410532f92a47dee245ce9b11ff71f578ebd763eb3bbea44ebd043d018fb" ;
|
|
|
+ passwordHash = CommonCryptogramUtil.doHashValue(CommonCryptogramUtil.doSm2Decrypt(password));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new CommonException(AuthExceptionEnum.PWD_DECRYPT_ERROR.getValue());
|
|
|
+ }
|
|
|
+ // 根据账号获取用户信息,根据B端或C端判断
|
|
|
+ if(SaClientTypeEnum.B.getValue().equals(type)) {
|
|
|
+ SaBaseLoginUser saBaseLoginUser = loginUserApi.getUserByAccount(account);
|
|
|
+ if(ObjectUtil.isEmpty(saBaseLoginUser)) {
|
|
|
+ throw new CommonException(AuthExceptionEnum.ACCOUNT_ERROR.getValue());
|
|
|
+ }
|
|
|
+ if (!saBaseLoginUser.getAccountType().equals(authAccountPasswordLoginParam.getAccountType())){
|
|
|
+ throw new CommonException("账号类型不匹配");
|
|
|
+ }
|
|
|
+ if (!saBaseLoginUser.getPassword().equals(passwordHash)) {
|
|
|
+ // 记录登录次数 和 过期时间
|
|
|
+ saveLoginTimes(account);
|
|
|
+ throw new CommonException(AuthExceptionEnum.PWD_ERROR.getValue());
|
|
|
+ }
|
|
|
+ // 删除redis 中的key
|
|
|
+ clearLoginErrorTimes(account);
|
|
|
+ // 执行B端登录
|
|
|
+ return execLoginB(saBaseLoginUser, device);
|
|
|
+ } else {
|
|
|
+ SaBaseClientLoginUser saBaseClientLoginUser = clientLoginUserApi.getClientUserByAccount(account);
|
|
|
+ if(ObjectUtil.isEmpty(saBaseClientLoginUser)) {
|
|
|
+ throw new CommonException(AuthExceptionEnum.ACCOUNT_ERROR.getValue());
|
|
|
+ }
|
|
|
+ if (!saBaseClientLoginUser.getPassword().equals(passwordHash)) {
|
|
|
+ throw new CommonException(AuthExceptionEnum.PWD_ERROR.getValue());
|
|
|
+ }
|
|
|
+ // 执行C端登录
|
|
|
+ return execLoginC(saBaseClientLoginUser, device);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ @Override
|
|
|
public String doLogin(AuthAccountPasswordLoginParam authAccountPasswordLoginParam, String type) {
|
|
|
// 判断账号是否被封禁
|
|
|
isDisableTime(authAccountPasswordLoginParam.getAccount());
|
|
@@ -233,8 +309,8 @@ public class AuthServiceImpl implements AuthService {
|
|
|
String passwordHash="";
|
|
|
try {
|
|
|
// 解密,并做哈希值
|
|
|
- passwordHash="207cf410532f92a47dee245ce9b11ff71f578ebd763eb3bbea44ebd043d018fb" ;
|
|
|
-// passwordHash = CommonCryptogramUtil.doHashValue(CommonCryptogramUtil.doSm2Decrypt(password));
|
|
|
+// passwordHash="207cf410532f92a47dee245ce9b11ff71f578ebd763eb3bbea44ebd043d018fb" ;
|
|
|
+ passwordHash = CommonCryptogramUtil.doHashValue(CommonCryptogramUtil.doSm2Decrypt(password));
|
|
|
} catch (Exception e) {
|
|
|
throw new CommonException(AuthExceptionEnum.PWD_DECRYPT_ERROR.getValue());
|
|
|
}
|