|
@@ -190,7 +190,63 @@ public class AuthServiceImpl implements AuthService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String doBLogin(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);
|
|
|
|
|
+ }
|
|
|
|
|
+ // SM2解密并获得前端传来的密码哈希值
|
|
|
|
|
+ String passwordHash;
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 解密,并做哈希值
|
|
|
|
|
+ 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.getEduIdentity().equals(authAccountPasswordLoginParam.getEduIdentity()))
|
|
|
|
|
+ {
|
|
|
|
|
+ throw new CommonException(AuthExceptionEnum.EDU_IDENTITY_ERROR.getValue());
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ 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
|
|
@Override
|
|
|
public String doLogin(AuthAccountPasswordLoginParam authAccountPasswordLoginParam, String type) {
|
|
public String doLogin(AuthAccountPasswordLoginParam authAccountPasswordLoginParam, String type) {
|
|
|
// 判断账号是否被封禁
|
|
// 判断账号是否被封禁
|
|
@@ -480,4 +536,6 @@ public class AuthServiceImpl implements AuthService {
|
|
|
return execLoginC(saBaseClientLoginUser, device);
|
|
return execLoginC(saBaseClientLoginUser, device);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|