邮箱-错误码
This commit is contained in:
@@ -927,8 +927,16 @@ public enum BusiStatus {
|
||||
PIC_UPLOAD_FAILED(20511, "PIC UPLOAD FAILED"),
|
||||
PIC_UPLOAD_REVIEW_EXCEPTION(500, "PIC UPLOAD REVIEW EXCEPTION!"),
|
||||
|
||||
EMAIL_FORMAT_ERROR(403, "Email format error");
|
||||
|
||||
EMAIL_CODE_SEND_SUCCESS(200, "邮件验证码發送成功"),
|
||||
EMAIL_FORMAT_ERROR(3011, "邮箱格式错误"),
|
||||
ACCOUNT_NOT_BIND_EMAIL(3012, "帐号未绑定邮箱"),
|
||||
ACCOUNT_BIND_EMAIL_DIFF(3013, "提交的邮箱不是当前帐号已绑定的邮箱"),
|
||||
EMAIL_BIND_TOO_MANY_ACCOUNT(3014, "該邮箱存在多個ID的綁定關係,請輸入用戶ID進行登錄"),
|
||||
INVALID_IDENTIFYING_EMAIL_CODE(3015, "邮件驗證碼不正確"),
|
||||
EMAIL_CODE_NOT_EXPIRED(3016, "已發送了驗證碼邮件.請等一分鐘后再試"),
|
||||
EMAIL_CODE_IP_TO_OFTEN(3019, "獲取邮件验证码過於頻繁"),
|
||||
EMAIL_VERIFY_CODE_ERROR(211174, "邮件驗證碼校驗失敗"),
|
||||
;
|
||||
|
||||
private final int value;
|
||||
|
||||
|
@@ -45,7 +45,7 @@ public class EmailService extends BaseService {
|
||||
String intervalKey = RedisKey.email_send_interval.getKey(emailAddress, type.toString());
|
||||
RBucket<String> intervalBucket = redissonClient.getBucket(intervalKey);
|
||||
if (intervalBucket.isExists()) {
|
||||
throw new ServiceException(BusiStatus.SMS_NOT_EXPIRED);
|
||||
throw new ServiceException(BusiStatus.EMAIL_CODE_NOT_EXPIRED);
|
||||
}
|
||||
|
||||
RRateLimiter rateLimiter = null;
|
||||
@@ -58,7 +58,7 @@ public class EmailService extends BaseService {
|
||||
|
||||
if (!rateLimiter.tryAcquire()){
|
||||
log.error("[email rateLimiter] {} {} 被限流了", ip, type);
|
||||
throw new ServiceException(BusiStatus.SMS_IP_TO_OFTEN);
|
||||
throw new ServiceException(BusiStatus.EMAIL_CODE_IP_TO_OFTEN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ public class EmailService extends BaseService {
|
||||
|
||||
public void validEmailAddress(String email){
|
||||
if (!isValidEmail(email)){
|
||||
log.error("[email] email format is invalid {}", email);
|
||||
throw new ServiceException(BusiStatus.EMAIL_FORMAT_ERROR);
|
||||
}
|
||||
}
|
||||
|
@@ -74,7 +74,7 @@ public class EmailController extends BaseController {
|
||||
|
||||
emailService.sendEmailCode(emailAddress, type, deviceInfo, ip, null, false);
|
||||
|
||||
return new BusiResult<>(BusiStatus.SMS_SEND_SUCCESS);
|
||||
return new BusiResult<>(BusiStatus.EMAIL_CODE_SEND_SUCCESS);
|
||||
}
|
||||
|
||||
@ApiParam("校验邮箱验证码")
|
||||
@@ -84,7 +84,7 @@ public class EmailController extends BaseController {
|
||||
|
||||
boolean verify = emailService.verifyEmailCode(emailAddress, code);
|
||||
if (!verify) {
|
||||
return BusiResult.fail(BusiStatus.SMS_VERIFY_CODE_ERROR);
|
||||
return BusiResult.fail(BusiStatus.EMAIL_VERIFY_CODE_ERROR);
|
||||
}
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
@@ -402,23 +402,23 @@ public class AccountManageService {
|
||||
* @return 1:成功 2:重置码无效 3:用户不存在
|
||||
*/
|
||||
public void resetPasswordByEmailCode(Long uid, String email, String password, String code) {
|
||||
if (!CommonUtil.checkEmailFormat(email)){
|
||||
throw new ServiceException(BusiStatus.ACCOUNT_NOT_BIND_PHONE);
|
||||
}
|
||||
emailService.validEmailAddress(email);
|
||||
|
||||
long count = accountService.countByEmail(email);
|
||||
if (count > 1L) {
|
||||
throw new ServiceException(BusiStatus.PHONE_BIND_TOO_MANY_ACCOUNT);
|
||||
throw new ServiceException(BusiStatus.EMAIL_BIND_TOO_MANY_ACCOUNT);
|
||||
}
|
||||
|
||||
Account account = accountService.getAccountByEmail(email);
|
||||
if (null == account || (null != uid && !account.getUid().equals(uid))) {
|
||||
throw new ServiceException(BusiStatus.PHONE_BIND_ERROR);
|
||||
if (null == account || !StringUtils.hasText(account.getPassword())) {
|
||||
throw new ServiceException(BusiStatus.ACCOUNT_NOT_BIND_EMAIL);
|
||||
} else if (null != uid && !account.getUid().equals(uid)) {
|
||||
throw new ServiceException(BusiStatus.ACCOUNT_BIND_EMAIL_DIFF);
|
||||
}
|
||||
|
||||
//检验验证码
|
||||
if (!emailService.verifyCodeByCache(email, code)) {
|
||||
throw new ServiceException(BusiStatus.INVALID_IDENTIFYING_CODE);
|
||||
throw new ServiceException(BusiStatus.INVALID_IDENTIFYING_EMAIL_CODE);
|
||||
}
|
||||
|
||||
accountService.resetAccountPwd(account.getUid(), password);
|
||||
|
Reference in New Issue
Block a user