feat: add register
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
package org.wfc.gateway.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.wfc.common.core.exception.CaptchaException;
|
||||
import org.wfc.common.core.web.domain.AjaxResult;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 验证码处理
|
||||
*
|
||||
@@ -19,5 +20,5 @@ public interface ValidateCodeService
|
||||
/**
|
||||
* 校验验证码
|
||||
*/
|
||||
public void checkCaptcha(String key, String value) throws CaptchaException;
|
||||
public void checkCaptcha(String key, String value, boolean isPic) throws CaptchaException;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.FastByteArrayOutputStream;
|
||||
import org.wfc.common.core.constant.CacheConstants;
|
||||
import org.wfc.common.core.constant.Constants;
|
||||
import org.wfc.common.core.constant.GlobalConstants;
|
||||
import org.wfc.common.core.exception.CaptchaException;
|
||||
import org.wfc.common.core.utils.StringUtils;
|
||||
import org.wfc.common.core.utils.sign.Base64;
|
||||
@@ -63,7 +63,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
||||
|
||||
// 保存验证码信息
|
||||
String uuid = IdUtils.simpleUUID();
|
||||
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
|
||||
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + uuid;
|
||||
|
||||
String capStr = null, code = null;
|
||||
BufferedImage image = null;
|
||||
@@ -109,19 +109,21 @@ public class ValidateCodeServiceImpl implements ValidateCodeService
|
||||
* 校验验证码
|
||||
*/
|
||||
@Override
|
||||
public void checkCaptcha(String code, String uuid) throws CaptchaException
|
||||
public void checkCaptcha(String code, String uuid, boolean isPic) throws CaptchaException
|
||||
{
|
||||
if (StringUtils.isEmpty(code))
|
||||
{
|
||||
throw new CaptchaException("user.jcaptcha.not.blank");
|
||||
}
|
||||
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
|
||||
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
|
||||
String captcha = redisService.getCacheObject(verifyKey);
|
||||
if (captcha == null)
|
||||
{
|
||||
throw new CaptchaException();
|
||||
}
|
||||
redisService.deleteObject(verifyKey);
|
||||
if (isPic) {
|
||||
redisService.deleteObject(verifyKey);
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha))
|
||||
{
|
||||
throw new CaptchaException();
|
||||
|
||||
Reference in New Issue
Block a user