Skip to content
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

Conversation

Canway-jessonwang
Copy link
Contributor

##变更点(Changes)
新增:密码过期提醒
##相关issue:
#117

)
.first()
.value
)
Copy link
Contributor

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)
Copy link
Contributor

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())
Copy link
Contributor

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要用t做变量,明确变量名意义

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expire_at => expired_at

Copy link
Contributor

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;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您的蓝鲸智云企业版平台密码<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>'
},
Copy link
Collaborator

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)
Copy link
Contributor

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():
Copy link
Contributor

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
Copy link
Contributor

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:
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

整合 密码过期 通知内容
"""
notice_config = {}
expire_at = (
Copy link
Contributor

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())
Copy link
Contributor

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}天后到期,"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

获取配置的逻辑 从expire_at -> expired_at,这里也要对应调整

@wklken
Copy link
Collaborator

wklken commented Jul 11, 2022

  1. 确认review点, 处理过的, 点resolve; (没处理的需要处理)
  2. 解冲突

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants