perf:优化登录次数校验
This commit is contained in:
@@ -43,9 +43,12 @@ public class CorePlatformUniqueService extends TsServiceBase<CorePlatformUniqueM
|
|||||||
*/
|
*/
|
||||||
public TokenBean login(DoLoginInfo loginInfo) {
|
public TokenBean login(DoLoginInfo loginInfo) {
|
||||||
|
|
||||||
int loginErrorTimes = coreLogLoginMapper.getLoginErrorTimes(loginInfo.getLoginIp());
|
int loginErrorTimes = tsLoginConfigurer.getLoginErrorTimes();
|
||||||
if (loginErrorTimes > 4) {
|
if (loginErrorTimes > 0) {
|
||||||
throw new ApiException("登录失败已达5次,请10分钟后再试");
|
int currentErrorTimes = coreLogLoginMapper.getLoginErrorTimes(loginInfo.getLoginIp());
|
||||||
|
if (currentErrorTimes >= loginErrorTimes) {
|
||||||
|
throw new ApiException("登录失败已达" + loginErrorTimes + "次,请10分钟后再试");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());
|
CorePlatformUnique platformUnique = getOneByColumn("unique_id", loginInfo.getUnique());
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public interface TsLoginConfigurer {
|
|||||||
/**
|
/**
|
||||||
* 登录失败的时候
|
* 登录失败的时候
|
||||||
*/
|
*/
|
||||||
default void onLoginError(String to,HttpServletResponse response) {
|
default void onLoginError(String to, HttpServletResponse response) {
|
||||||
ServletKit.write(response, "404", "text");
|
ServletKit.write(response, "404", "text");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,4 +66,14 @@ public interface TsLoginConfigurer {
|
|||||||
*/
|
*/
|
||||||
RequestUserInfo getCurrentUserName(TokenBean userId);
|
RequestUserInfo getCurrentUserName(TokenBean userId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取登录失败的次数,默认5次
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
default int getLoginErrorTimes() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user