多因素登录
This commit is contained in:
@ -2,7 +2,7 @@ package com.chinaunicom.mall.ebtp.extend.shortmessage.controller;
|
|||||||
|
|
||||||
|
|
||||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||||
import com.chinaunicom.mall.ebtp.extend.shortmessage.entity.SmsSendRequest;
|
import com.chinaunicom.mall.ebtp.extend.shortmessage.entity.AuthCodeVo;
|
||||||
import com.chinaunicom.mall.ebtp.extend.shortmessage.utils.RSA;
|
import com.chinaunicom.mall.ebtp.extend.shortmessage.utils.RSA;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@ -16,7 +16,6 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.annotations.ApiParam;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.chinaunicom.mall.ebtp.extend.shortmessage.entity.BizShortMessage;
|
import com.chinaunicom.mall.ebtp.extend.shortmessage.entity.BizShortMessage;
|
||||||
import com.chinaunicom.mall.ebtp.extend.shortmessage.service.BizShortMessageService;
|
import com.chinaunicom.mall.ebtp.extend.shortmessage.service.BizShortMessageService;
|
||||||
@ -43,10 +42,10 @@ public class BizShortMessageController{
|
|||||||
* authCode 验证码
|
* authCode 验证码
|
||||||
* callbackUrl UrlEncode编码 应用系统回调确认用户有效性的地址,应用系统传了这个地址则用户有效性由该地址确定
|
* callbackUrl UrlEncode编码 应用系统回调确认用户有效性的地址,应用系统传了这个地址则用户有效性由该地址确定
|
||||||
*/
|
*/
|
||||||
@GetMapping("/send/authCode")
|
@PostMapping("/send/authCode")
|
||||||
public BaseResponse<Boolean> authCodeSend(@RequestParam(name = "mobile") String mobile){
|
public BaseResponse<Boolean> authCodeSend(@RequestBody AuthCodeVo vo){
|
||||||
log.info("解密前:"+mobile);
|
log.info("解密前:"+vo.getMobile());
|
||||||
String value = RSA.decrypt(mobile,privateKey);
|
String value = RSA.decrypt(vo.getMobile(),privateKey);
|
||||||
log.info("解密后:"+value);
|
log.info("解密后:"+value);
|
||||||
return BaseResponse.success(iBizShortMessageService.authCodeSend(value));
|
return BaseResponse.success(iBizShortMessageService.authCodeSend(value));
|
||||||
}
|
}
|
||||||
@ -61,13 +60,12 @@ public class BizShortMessageController{
|
|||||||
* authCode 验证码
|
* authCode 验证码
|
||||||
* callbackUrl UrlEncode编码 应用系统回调确认用户有效性的地址,应用系统传了这个地址则用户有效性由该地址确定
|
* callbackUrl UrlEncode编码 应用系统回调确认用户有效性的地址,应用系统传了这个地址则用户有效性由该地址确定
|
||||||
*/
|
*/
|
||||||
@GetMapping("/check/authCode")
|
@PostMapping("/check/authCode")
|
||||||
public BaseResponse<Boolean> authCodeCheck(@RequestParam(name = "mobile")String mobile,
|
public BaseResponse<Boolean> authCodeCheck(@RequestBody AuthCodeVo vo){
|
||||||
@RequestParam(name = "authCode") String authCode){
|
log.info("解密前:"+vo.getMobile());
|
||||||
log.info("解密前:"+mobile);
|
String value = RSA.decrypt(vo.getMobile(),privateKey);
|
||||||
String value = RSA.decrypt(mobile,privateKey);
|
|
||||||
log.info("解密后:"+value);
|
log.info("解密后:"+value);
|
||||||
return BaseResponse.success(iBizShortMessageService.authCodeCheck(value, authCode));
|
return BaseResponse.success(iBizShortMessageService.authCodeCheck(value, vo.getAuthCode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.chinaunicom.mall.ebtp.extend.shortmessage.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AuthCodeVo {
|
||||||
|
private String mobile;
|
||||||
|
private String authCode;
|
||||||
|
}
|
@ -98,6 +98,7 @@ public class BizShortMessageServiceImpl extends BaseServiceImpl<BizShortMessageM
|
|||||||
@Override
|
@Override
|
||||||
public Boolean authCodeCheck(String mobile, String authCode) {
|
public Boolean authCodeCheck(String mobile, String authCode) {
|
||||||
Object userId = redisTemplate.opsForValue().get("userId:" + mobile);
|
Object userId = redisTemplate.opsForValue().get("userId:" + mobile);
|
||||||
|
CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.assertNotNullByKey("验证码已失效",userId);
|
||||||
QueryWrapper<BizShortMessage> query = new QueryWrapper<>(new BizShortMessage().setId(userId.toString()).setMobile(mobile));
|
QueryWrapper<BizShortMessage> query = new QueryWrapper<>(new BizShortMessage().setId(userId.toString()).setMobile(mobile));
|
||||||
BizShortMessage message = this.getBaseMapper().selectOne(query);
|
BizShortMessage message = this.getBaseMapper().selectOne(query);
|
||||||
Object value = redisTemplate.opsForValue().get("user:" + mobile);
|
Object value = redisTemplate.opsForValue().get("user:" + mobile);
|
||||||
|
Reference in New Issue
Block a user