mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-03 00:15:20 +00:00
feat: user login acl (#6963)
* feat: user login acl * 添加分时登陆 * acl 部分还原 * 简化acl判断逻辑 Co-authored-by: feng626 <1304903146@qq.com> Co-authored-by: feng626 <57284900+feng626@users.noreply.github.com>
This commit is contained in:
18
apps/common/utils/time_period.py
Normal file
18
apps/common/utils/time_period.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from common.utils.timezone import now
|
||||
|
||||
|
||||
def contains_time_period(time_periods):
|
||||
"""
|
||||
time_periods: [{"id": 1, "value": "00:00~07:30、10:00~13:00"}, {"id": 2, "value": "00:00~00:00"}]
|
||||
"""
|
||||
if not time_periods:
|
||||
return False
|
||||
|
||||
current_time = now().strftime('%H:%M')
|
||||
today_time_period = next(filter(lambda x: str(x['id']) == now().strftime("%w"), time_periods))
|
||||
for time in today_time_period['value'].split('、'):
|
||||
start, end = time.split('~')
|
||||
end = "24:00" if end == "00:00" else end
|
||||
if start <= current_time <= end:
|
||||
return True
|
||||
return False
|
Reference in New Issue
Block a user