|
@@ -197,7 +197,6 @@ public class LoginServiceImpl implements LoginService {
|
|
// 返回登录校验结果
|
|
// 返回登录校验结果
|
|
return logonVerify(baseUser);
|
|
return logonVerify(baseUser);
|
|
}
|
|
}
|
|
-
|
|
|
|
} else {
|
|
} else {
|
|
return ResponseJson.error("验证码不匹配,请重新输入");
|
|
return ResponseJson.error("验证码不匹配,请重新输入");
|
|
}
|
|
}
|
|
@@ -695,6 +694,7 @@ public class LoginServiceImpl implements LoginService {
|
|
@Override
|
|
@Override
|
|
public ResponseJson<UserLoginVo> qrCodeAuthScanBind(ScanBindDto scanBindDto) {
|
|
public ResponseJson<UserLoginVo> qrCodeAuthScanBind(ScanBindDto scanBindDto) {
|
|
String mobileOrEmail = null;
|
|
String mobileOrEmail = null;
|
|
|
|
+
|
|
if (!ObjectUtils.isEmpty(scanBindDto.getMobileOrEmail())) {
|
|
if (!ObjectUtils.isEmpty(scanBindDto.getMobileOrEmail())) {
|
|
mobileOrEmail = scanBindDto.getMobileOrEmail();
|
|
mobileOrEmail = scanBindDto.getMobileOrEmail();
|
|
}
|
|
}
|
|
@@ -1084,41 +1084,70 @@ public class LoginServiceImpl implements LoginService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public ResponseJson<String> operateVerification(LoginCodeDto loginCodeDto) {
|
|
public ResponseJson<String> operateVerification(LoginCodeDto loginCodeDto) {
|
|
- if (ObjectUtils.isEmpty(loginCodeDto.getMobile())) {
|
|
|
|
- return ResponseJson.error("请输入手机号",null);
|
|
|
|
- }
|
|
|
|
- if (ObjectUtils.isEmpty(loginCodeDto.getCode())) {
|
|
|
|
- return ResponseJson.error("请输入验证码",null);
|
|
|
|
- }
|
|
|
|
- String mobile = loginCodeDto.getMobile();
|
|
|
|
- String code = loginCodeDto.getCode();
|
|
|
|
- String result = ValidateUtil.validateMobile(mobile);
|
|
|
|
-
|
|
|
|
- if (result != null) {
|
|
|
|
- return ResponseJson.error(result);
|
|
|
|
|
|
+
|
|
|
|
+ // 验证码或者账号密码
|
|
|
|
+ String codeType = null;
|
|
|
|
+ if (!ObjectUtils.isEmpty(loginCodeDto.getCodeType())) {
|
|
|
|
+ codeType = loginCodeDto.getCodeType();
|
|
}
|
|
}
|
|
- // 判断redis中是否存在
|
|
|
|
- boolean exists = redisService.exists("code:" + mobile);
|
|
|
|
- if (exists) {
|
|
|
|
- // 校验验证码是否过期
|
|
|
|
- long expireTime = redisService.getExpireTime("code:" + mobile);
|
|
|
|
- if (expireTime < 0) {
|
|
|
|
- return ResponseJson.error("验证码已失效,请重新获取");
|
|
|
|
|
|
+ // 账号密码验证
|
|
|
|
+ if ("0".equals(codeType)) {
|
|
|
|
+ if (ObjectUtils.isEmpty(loginCodeDto.getMobileOrEmail())) {
|
|
|
|
+ return ResponseJson.error("请输入账号",null);
|
|
}
|
|
}
|
|
- // 获取redis缓存验证码
|
|
|
|
- Object randomCode = redisService.get("code:" + mobile);
|
|
|
|
- if (!ObjectUtils.isEmpty(randomCode)) {
|
|
|
|
- if (code.equals(randomCode.toString())) {
|
|
|
|
- redisService.remove("code:"+mobile);
|
|
|
|
- return ResponseJson.success("验证码匹配成功");
|
|
|
|
|
|
+ if (ObjectUtils.isEmpty(loginCodeDto.getPassword())) {
|
|
|
|
+ return ResponseJson.error("请输入密码",null);
|
|
|
|
+ }
|
|
|
|
+ // 账号
|
|
|
|
+ String mobileOrEmail = loginCodeDto.getMobileOrEmail();
|
|
|
|
+ // 密码
|
|
|
|
+ String password = loginCodeDto.getPassword();
|
|
|
|
+
|
|
|
|
+ // 根据手机号或者邮箱获取账户信息
|
|
|
|
+ UserLoginVo user = loginMapper.getLoginUserByMobileOrEmail(mobileOrEmail);
|
|
|
|
+ // 账号密码验证
|
|
|
|
+ String md5Password = Md5Util.md5(password);
|
|
|
|
+ if (md5Password.equals(user.getPassword())) {
|
|
|
|
+ return ResponseJson.success("账号与密码匹配成功");
|
|
|
|
+ }
|
|
|
|
+ return ResponseJson.error("账号与密码不匹配,请检查后重新输入");
|
|
|
|
+ } else {
|
|
|
|
+ // 手机短信验证
|
|
|
|
+ if (ObjectUtils.isEmpty(loginCodeDto.getMobile())) {
|
|
|
|
+ return ResponseJson.error("请输入手机号",null);
|
|
|
|
+ }
|
|
|
|
+ if (ObjectUtils.isEmpty(loginCodeDto.getCode())) {
|
|
|
|
+ return ResponseJson.error("请输入验证码",null);
|
|
|
|
+ }
|
|
|
|
+ String mobile = loginCodeDto.getMobile();
|
|
|
|
+ String code = loginCodeDto.getCode();
|
|
|
|
+ String result = ValidateUtil.validateMobile(mobile);
|
|
|
|
+ if (result != null) {
|
|
|
|
+ return ResponseJson.error(result);
|
|
|
|
+ }
|
|
|
|
+ // 判断redis中是否存在
|
|
|
|
+ boolean exists = redisService.exists("code:" + mobile);
|
|
|
|
+ if (exists) {
|
|
|
|
+ // 校验验证码是否过期
|
|
|
|
+ long expireTime = redisService.getExpireTime("code:" + mobile);
|
|
|
|
+ if (expireTime < 0) {
|
|
|
|
+ return ResponseJson.error("验证码已失效,请重新获取");
|
|
|
|
+ }
|
|
|
|
+ // 获取redis缓存验证码
|
|
|
|
+ Object randomCode = redisService.get("code:" + mobile);
|
|
|
|
+ if (!ObjectUtils.isEmpty(randomCode)) {
|
|
|
|
+ if (code.equals(randomCode.toString())) {
|
|
|
|
+ redisService.remove("code:" + mobile);
|
|
|
|
+ return ResponseJson.success("验证码匹配成功");
|
|
|
|
+ } else {
|
|
|
|
+ return ResponseJson.error("验证码不匹配,请重新输入");
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- return ResponseJson.error("验证码不匹配,请重新输入");
|
|
|
|
|
|
+ return ResponseJson.error("验证码错误,请重新获取");
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
return ResponseJson.error("验证码错误,请重新获取");
|
|
return ResponseJson.error("验证码错误,请重新获取");
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- return ResponseJson.error("验证码错误,请重新获取");
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|