-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
密码过期 #521
密码过期 #521
Conversation
) | ||
.first() | ||
.value | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这边可以通过configprovider 获取notice_interval
valid_period = datetime.timedelta(days=profile["password_valid_days"]) | ||
expire_at = (profile["password_update_time"] or profile["create_time"]) + valid_period | ||
if expire_at.date() in expiration_times: | ||
expiring_profile_list.append(profile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expiring_profile_list => unexpire_profile_list
""" | ||
notice_config = {} | ||
expire_at = ( | ||
(profile["password_update_time"].date() or profile["create_time"].date()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
提取出来,用三元表达式
获取需要进行通知的 过期时间列表 | ||
""" | ||
expiration_times = [] | ||
for t in notice_interval: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要用t做变量,明确变量名意义
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, 这部分跟ft分支 我调整的部分 同步更新就可以
if NOTICE_METHOD_EMAIL in notice_methods: | ||
email_config = ( | ||
config_loader["expired_password_email_config"] | ||
if expire_at.days < 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expire_at => expired_at
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
"sender": "蓝鲸智云企业版", | ||
"content": "{username},您好!您的蓝鲸智云企业版平台密码已过期,为避免影响使用,请尽快登陆平台({url})修改密码。蓝鲸智云平台用户管理处", | ||
"content_html": '<p style="text-align: left;">Jake,您好:</p><p style="text-align: left;"> 您的蓝鲸智云企业版平台密码<span style="color: rgb(225, 60, 57);">已过期</span>,为避免影响使用,请尽快登陆平台(<a href="https://www.baidu.com/" target="_blank">https://www.baidu.com/</a>)修改密码。</p><p style="text-align: left;">蓝鲸智云平台用户管理处</p>' | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
企业版/社区版字样需要全部去掉
"password_update_time", | ||
"create_time", | ||
) | ||
expiration_times = get_expiration_dates(notice_interval) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expiration_times to expiration_dates
expire_at = (profile["password_update_time"] or profile["create_time"]) + valid_period | ||
if expire_at.date() in expiration_times: | ||
expiring_profile_list.append(profile) | ||
if expire_at.date() < datetime.date.today(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expire_at to expired_at
expiration_times = get_expiration_dates(notice_interval) | ||
for profile in expire_profiles: | ||
valid_period = datetime.timedelta(days=profile["password_valid_days"]) | ||
expire_at = (profile["password_update_time"] or profile["create_time"]) + valid_period |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expire_at to expired_at
获取需要进行通知的 过期时间列表 | ||
""" | ||
expiration_times = [] | ||
for t in notice_interval: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, 这部分跟ft分支 我调整的部分 同步更新就可以
if NOTICE_METHOD_EMAIL in notice_methods: | ||
email_config = ( | ||
config_loader["expired_password_email_config"] | ||
if expire_at.days < 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
|
||
message = ( | ||
email_config["content"].format(username=profile["username"], url=settings.LOGIN_REDIRECT_TO) | ||
if expire_at.days < 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
整合 密码过期 通知内容 | ||
""" | ||
notice_config = {} | ||
expire_at = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expire_at to expired_at
@@ -132,3 +139,40 @@ def account_status_test(): | |||
status__in=[ProfileStatus.NORMAL.value, ProfileStatus.DISABLED.value], | |||
) | |||
expired_profiles.update(status=ProfileStatus.EXPIRED.value) | |||
|
|||
|
|||
@periodic_task(run_every=crontab()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
crontab时间配置?
example={ | ||
"title": "【蓝鲸智云企业版】密码到期提醒", | ||
"sender": "蓝鲸智云", | ||
"content": "{username},您好:您的蓝鲸智云平台账号将于{expire_at}天后到期," |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
获取配置的逻辑 从expire_at -> expired_at,这里也要对应调整
|
##变更点(Changes)
新增:密码过期提醒
##相关issue:
#117