|
@@ -7,6 +7,7 @@ import cn.reghao.tnb.account.api.constant.VerifyChannel;
|
|
|
import cn.reghao.tnb.account.api.dto.VerifyCode;
|
|
import cn.reghao.tnb.account.api.dto.VerifyCode;
|
|
|
import cn.reghao.tnb.account.app.db.repository.AccountRepository;
|
|
import cn.reghao.tnb.account.app.db.repository.AccountRepository;
|
|
|
import cn.reghao.tnb.account.app.model.po.UserAccount;
|
|
import cn.reghao.tnb.account.app.model.po.UserAccount;
|
|
|
|
|
+import cn.reghao.tnb.account.app.model.po.UserRegistry;
|
|
|
import cn.reghao.tnb.account.app.util.CaptchaUtil;
|
|
import cn.reghao.tnb.account.app.util.CaptchaUtil;
|
|
|
import cn.reghao.tnb.account.app.redis.RedisKeys;
|
|
import cn.reghao.tnb.account.app.redis.RedisKeys;
|
|
|
import cn.reghao.tnb.account.app.redis.ds.RedisString;
|
|
import cn.reghao.tnb.account.app.redis.ds.RedisString;
|
|
@@ -44,8 +45,13 @@ public class CodeService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public InputStream generateCaptcha() throws IOException {
|
|
public InputStream generateCaptcha() throws IOException {
|
|
|
- String captchaCode = RandomString.getString(5);
|
|
|
|
|
- //captchaCode = "ab8il";
|
|
|
|
|
|
|
+ String captchaCode;
|
|
|
|
|
+ UserRegistry userRegistry = accountRepository.getUserRegistry();
|
|
|
|
|
+ if (!userRegistry.getEnableCode()) {
|
|
|
|
|
+ captchaCode = RandomString.getString(5);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ captchaCode = userRegistry.getCaptchaCode();
|
|
|
|
|
+ }
|
|
|
redisString.setWithTimeout(RedisKeys.getCaptchaKey(), captchaCode, sessionTimeout);
|
|
redisString.setWithTimeout(RedisKeys.getCaptchaKey(), captchaCode, sessionTimeout);
|
|
|
|
|
|
|
|
ByteArrayOutputStream baos = CaptchaUtil.captchaWithDisturb(captchaCode, 130, 48);
|
|
ByteArrayOutputStream baos = CaptchaUtil.captchaWithDisturb(captchaCode, 130, 48);
|
|
@@ -60,8 +66,8 @@ public class CodeService {
|
|
|
Integer channel = verifyCode.getChannel();
|
|
Integer channel = verifyCode.getChannel();
|
|
|
String receiver = verifyCode.getReceiver();
|
|
String receiver = verifyCode.getReceiver();
|
|
|
|
|
|
|
|
- boolean registry = accountRepository.getUserRegistry().getEnabled();
|
|
|
|
|
- if (channel == VerifyChannel.registryChannel.getValue() && !registry) {
|
|
|
|
|
|
|
+ UserRegistry userRegistry = accountRepository.getUserRegistry();
|
|
|
|
|
+ if (channel == VerifyChannel.registryChannel.getValue() && !userRegistry.getEnabled()) {
|
|
|
return Result.fail("系统当前未开放注册");
|
|
return Result.fail("系统当前未开放注册");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -81,8 +87,13 @@ public class CodeService {
|
|
|
return Result.fail("邮箱/手机号已存在");
|
|
return Result.fail("邮箱/手机号已存在");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- String code = RandomString.getNumber(6);
|
|
|
|
|
- code = "220233";
|
|
|
|
|
|
|
+ String code;
|
|
|
|
|
+ if (userRegistry.getEnableCode()) {
|
|
|
|
|
+ code = userRegistry.getVerifyCode();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ code = RandomString.getNumber(6);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
redisString.setWithTimeout(RedisKeys.getVerifyCodeKey(channel, receiver), code, sessionTimeout);
|
|
redisString.setWithTimeout(RedisKeys.getVerifyCodeKey(channel, receiver), code, sessionTimeout);
|
|
|
|
|
|
|
|
String title = "验证码";
|
|
String title = "验证码";
|