Skip to content

Commit

Permalink
新控制台登陆1小时限制次数支持通过配置文件设置
Browse files Browse the repository at this point in the history
  • Loading branch information
heqingpan committed Dec 20, 2023
1 parent 1ebb77c commit 2d894f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/console/login_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub async fn login(
let limit_key = Arc::new(format!("USER_L#{}", &param.username));
let limit_req = CacheLimiterReq::Hour {
key: limit_key.clone(),
limit: 5,
limit: app.sys_config.console_login_one_hour_limit as i32,
};
//登录前先判断是否登陆准入
if let Ok(CacheManagerResult::Limiter(acquire_result)) =
Expand Down
7 changes: 5 additions & 2 deletions src/raft/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,11 @@ impl Handler<CacheLimiterReq> for CacheManager {

let limiter_data: LimiterData = limiter.into();
let cache_value = CacheValue::String(Arc::new(limiter_data.to_string()));
self.cache
.set(key.clone(), cache_value.clone(), rate_to_ms_conversion/1000);
self.cache.set(
key.clone(),
cache_value.clone(),
rate_to_ms_conversion / 1000,
);

let mut cache_do: CacheItemDo = cache_value.into();
cache_do.timeout = ((now + rate_to_ms_conversion as i64) / 1000) as i32;
Expand Down

0 comments on commit 2d894f2

Please sign in to comment.