Commit 17bf3245 by 张晋雄

短信验证登陆

parent c11a31f4
...@@ -108,7 +108,12 @@ public class AuthenticationServiceImpl implements IAuthenticationService { ...@@ -108,7 +108,12 @@ public class AuthenticationServiceImpl implements IAuthenticationService {
@Override @Override
public AuthenticationResult smsAuthentication(String mobile, String verifyCode) throws UserServiceException, AuthenticationServiceException { public AuthenticationResult smsAuthentication(String mobile, String verifyCode) throws UserServiceException, AuthenticationServiceException {
//1.检查验证码是否正确 //1. 查找用户是否存在
UserAuthLocal userAuthLocal = userAuthLocalService.getByMobile(mobile);
if (null == userAuthLocal) {
throw new AuthenticationServiceException(AuthenticationErrorCode.USER_NOT_FOUND);
}
//2.检查验证码是否正确
String realVerifyCode = redisHelper.get(RedisKey.VERIFY_CODE_KEY(mobile)); String realVerifyCode = redisHelper.get(RedisKey.VERIFY_CODE_KEY(mobile));
if (StringUtils.isEmpty(realVerifyCode) || !realVerifyCode.equals(verifyCode)) { if (StringUtils.isEmpty(realVerifyCode) || !realVerifyCode.equals(verifyCode)) {
throw new UserServiceException(UserErrorCode.REG_VERIFY_CODE_ERROR); throw new UserServiceException(UserErrorCode.REG_VERIFY_CODE_ERROR);
...@@ -117,11 +122,6 @@ public class AuthenticationServiceImpl implements IAuthenticationService { ...@@ -117,11 +122,6 @@ public class AuthenticationServiceImpl implements IAuthenticationService {
// 删除验证码 // 删除验证码
redisHelper.del(RedisKey.VERIFY_CODE_KEY(mobile)); redisHelper.del(RedisKey.VERIFY_CODE_KEY(mobile));
//2. 查找用户是否存在
UserAuthLocal userAuthLocal = userAuthLocalService.getByMobile(mobile);
if (null == userAuthLocal) {
throw new AuthenticationServiceException(AuthenticationErrorCode.USER_NOT_FOUND);
}
// 根据userId生成token并返回 // 根据userId生成token并返回
return makeAuthenticationResult(userAuthLocal.getUserId()); return makeAuthenticationResult(userAuthLocal.getUserId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment