|
@@ -47,6 +47,9 @@ import cn.com.qmth.examcloud.core.basic.service.AuthService;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.SysConfigService;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.UserService;
|
|
|
import cn.com.qmth.examcloud.core.basic.service.bean.LoginInfo;
|
|
|
+import cn.com.qmth.examcloud.exchange.inner.api.SendSmsCloudService;
|
|
|
+import cn.com.qmth.examcloud.exchange.inner.api.request.CheckSmsCodeReq;
|
|
|
+import cn.com.qmth.examcloud.exchange.inner.api.response.CheckIdentifyingCodeResp;
|
|
|
|
|
|
/**
|
|
|
* 类注释
|
|
@@ -91,6 +94,9 @@ public class AuthServiceImpl implements AuthService {
|
|
|
@Autowired
|
|
|
SysConfigService sysConfigService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ SendSmsCloudService sendSmsCloudService;
|
|
|
+
|
|
|
@Override
|
|
|
public User login(LoginInfo loginInfo) {
|
|
|
|
|
@@ -98,6 +104,7 @@ public class AuthServiceImpl implements AuthService {
|
|
|
String accountValue = loginInfo.getAccountValue();
|
|
|
String password = loginInfo.getPassword();
|
|
|
String clientIp = loginInfo.getClientIp();
|
|
|
+ String smsCode = loginInfo.getSmsCode();
|
|
|
|
|
|
if (StringUtils.isBlank(accountType)) {
|
|
|
throw new StatusException("B-001201", "accountType is null");
|
|
@@ -216,10 +223,25 @@ public class AuthServiceImpl implements AuthService {
|
|
|
if (null != student.getEnable() && !student.getEnable()) {
|
|
|
throw new StatusException("B-001005", "账户被禁用");
|
|
|
}
|
|
|
- String rightPassword = student.getPassword();
|
|
|
- if (!rightPassword.equals(password)) {
|
|
|
- whenPasswordError(accountTypeEnum, accountValue, clientIp);
|
|
|
- throw new StatusException("B-001003", "账号或密码错误");
|
|
|
+
|
|
|
+ // 验证码登录
|
|
|
+ if (AccountType.STUDENT_PHONE.equals(accountTypeEnum)
|
|
|
+ && StringUtils.isNotBlank(smsCode)) {
|
|
|
+ CheckSmsCodeReq req = new CheckSmsCodeReq();
|
|
|
+ req.setCode(smsCode);
|
|
|
+ req.setPhone(accountValue);
|
|
|
+ CheckIdentifyingCodeResp resp = sendSmsCloudService.checkIdentifyingCode(req);
|
|
|
+ if (!resp.getSuccess()) {
|
|
|
+ throw new StatusException("B-001050", "验证码错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 密码登录
|
|
|
+ else {
|
|
|
+ String rightPassword = student.getPassword();
|
|
|
+ if (!rightPassword.equals(password)) {
|
|
|
+ whenPasswordError(accountTypeEnum, accountValue, clientIp);
|
|
|
+ throw new StatusException("B-001003", "账号或密码错误");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
user.setUserId(student.getId());
|