新增检查验证码
This commit is contained in:
parent
7c3a605c2f
commit
3b76b115b7
@ -1,6 +1,8 @@
|
|||||||
package com.cm.manager.sms.manager;
|
package com.cm.manager.sms.manager;
|
||||||
|
|
||||||
|
import com.cm.common.exception.ParamsException;
|
||||||
import com.cm.manager.sms.pojo.VerificationCode;
|
import com.cm.manager.sms.pojo.VerificationCode;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -88,6 +90,23 @@ public class VerificationCodeManager {
|
|||||||
verificationCodeMap.remove(key);
|
verificationCodeMap.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验验证码
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @param code
|
||||||
|
*/
|
||||||
|
public void checkVerificationCode(String key, String code) {
|
||||||
|
String verificationCode = getVerificationCode(key);
|
||||||
|
if (StringUtils.isBlank(verificationCode)) {
|
||||||
|
throw new ParamsException("验证码无效");
|
||||||
|
}
|
||||||
|
if (!StringUtils.equals(code, verificationCode)) {
|
||||||
|
throw new ParamsException("验证码不匹配");
|
||||||
|
}
|
||||||
|
clearUsedVerificationCode(key);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除过期验证码
|
* 删除过期验证码
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user