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:
fit2bot
2021-10-20 17:56:59 +08:00
committed by GitHub
parent 9424929dde
commit 9acfd461b4
32 changed files with 325 additions and 206 deletions

View 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