v1.0.22 #31
+12
-4
@@ -66,6 +66,7 @@ public class GaoUserInviteServiceImplement implements GaoUserInviteService {
|
|||||||
private static final long REGISTER_RATE_LIMIT_TTL = Time.M * 10;
|
private static final long REGISTER_RATE_LIMIT_TTL = Time.M * 10;
|
||||||
private static final int CODE_RATE_LIMIT = 30;
|
private static final int CODE_RATE_LIMIT = 30;
|
||||||
private static final int REGISTER_VALUE_RATE_LIMIT = 10;
|
private static final int REGISTER_VALUE_RATE_LIMIT = 10;
|
||||||
|
private static final String INVALID_INVITE_MESSAGE = "邀请码无效或已过期";
|
||||||
|
|
||||||
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
|
private static final SecureRandom SECURE_RANDOM = new SecureRandom();
|
||||||
|
|
||||||
@@ -152,9 +153,16 @@ public class GaoUserInviteServiceImplement implements GaoUserInviteService {
|
|||||||
public GaoUserInviteValidateResponse validate(String code) {
|
public GaoUserInviteValidateResponse validate(String code) {
|
||||||
TimiException.required(code, "not found code");
|
TimiException.required(code, "not found code");
|
||||||
checkCodeRateLimit(code);
|
checkCodeRateLimit(code);
|
||||||
GaoUserInviteCache cache = requireValidInvite(code);
|
try {
|
||||||
validateInviteTarget(cache);
|
GaoUserInviteCache cache = requireValidInvite(code);
|
||||||
return new GaoUserInviteValidateResponse(true, cache.getExpireAt());
|
validateInviteTarget(cache);
|
||||||
|
return new GaoUserInviteValidateResponse(true, cache.getExpireAt());
|
||||||
|
} catch (TimiException e) {
|
||||||
|
if (TimiCode.ARG_BAD == e.getCode() && INVALID_INVITE_MESSAGE.equals(e.getMessage())) {
|
||||||
|
return new GaoUserInviteValidateResponse(false, -1L);
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||||
@@ -354,7 +362,7 @@ public class GaoUserInviteServiceImplement implements GaoUserInviteService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TimiException invalidInvite() {
|
private TimiException invalidInvite() {
|
||||||
return new TimiException(TimiCode.ARG_BAD, "邀请码无效或已过期");
|
return new TimiException(TimiCode.ARG_BAD, INVALID_INVITE_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCoreAdmin() {
|
private boolean isCoreAdmin() {
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ public class GaoUserInviteValidateResponse {
|
|||||||
/// true 为邀请码可用
|
/// true 为邀请码可用
|
||||||
private boolean valid;
|
private boolean valid;
|
||||||
|
|
||||||
/// 邀请过期时间,毫秒时间戳
|
/// 邀请过期时间,毫秒时间戳;valid 为 false 时为 0
|
||||||
private Long expireAt;
|
private Long expireAt;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user