Skip to content

Commit

Permalink
feat: 支持密码过期返回token重置密码链接 & 支持初始密码强制修改
Browse files Browse the repository at this point in the history
  • Loading branch information
IMBlues authored and v_yutyi committed Dec 9, 2021
1 parent 14a366c commit c95bd5e
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/api/bkuser_core/profiles/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,20 @@ def _generate_reset_passwd_url_with_token(profile: Profile) -> dict:

return data

@staticmethod
def _generate_reset_passwd_url_with_token(profile: Profile) -> dict:
data = {}
try:
token_holder = ProfileTokenHolder.objects.create(
profile=profile, token_expire_seconds=settings.PAGE_TOKEN_EXPIRE_SECONDS
)
except Exception: # pylint: disable=broad-except
logger.exception("failed to create token for password reset")
else:
data.update({"reset_password_url": make_passwd_reset_url_by_token(token_holder.token)})

return data

@method_decorator(clear_cache_if_succeed)
@swagger_auto_schema(request_body=local_serializers.LoginUpsertSerializer)
def upsert(self, request):
Expand Down
80 changes: 80 additions & 0 deletions src/login/bklogin/templates/account/login_ce_i18n.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{% load i18n %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="icon" type="image/x-icon" href="{{STATIC_URL}}favicon.ico">
<link href="{{STATIC_URL}}css_ce/bk.{{CSS_SUFFIX}}" rel="stylesheet" type="text/css" />
<link href="{{STATIC_URL}}assets/bk-icon-2.0/iconfont.css" rel="stylesheet" type="text/css" />
<link href="{{STATIC_URL}}css_ce/login.{{CSS_SUFFIX}}?v={{STATIC_VERSION}}" rel="stylesheet" type="text/css" />
<title>{% trans '登录|蓝鲸智云' %}</title>
</head>
<body>
<div class="page-content">
<div class="login-from">
<div class="logo-title">
<img src="{{STATIC_URL}}img/logo_ce/bk_login.png" height="32" width="311" alt="">
</div>
<div class="from-detail">
<form action="{{ app_path }}" method="post" id="login-form" onsubmit="return refresh_token()">{% csrf_token %}
<div class="is-danger-tip">
{% if error_message %}
<i class="bk-icon icon-exclamation-circle-shape"></i><span>{{ error_message }}</span>
{% if token_set_password_url %}
<a href="{{ token_set_password_url }}" target="_blank">>>{% trans '去修改' %}</a>
{% endif %}
{% endif %}
</div>
<div class="form-login">
<div class="user group-control">
<i class="bk-icon icon-user"></i>
<input id="user" type="text" name="username" placeholder="{% trans '请输入用户名' %}" >
</div>
<div class="pwd group-control">
<i class="bk-icon icon-password"></i>
<input class="password" id="password" type="password" name="password" value="" placeholder="{% trans '请输入用户密码' %}">
</div>
<div>
<input type="hidden" name="next" value="{{ next }}" />
<input type="hidden" name="app_id" value="{{app_id }}">
</div>
<div class="btn-content clearfix">
<button class="login-btn">{% trans '登录' %}</button>
<span class="protocol-btn">{% trans '查看用户协议' %}</span>
</div>
</div>
</form>
</div>
</div>
<footer class="footer">
<p>
<a id="contact_us" class="link">{% trans 'QQ咨询' %}(800802001)</a>
| <a href="http://bbs.bk.tencent.com/forum.php" target="_blank" hotrep="hp.footer.feedback" class="link">{% trans '蓝鲸论坛' %}</a>
| <a href="http://bk.tencent.com/" target="_blank" hotrep="hp.footer.feedback" class="link">{% trans '蓝鲸官网' %}</a>
| <a href="/" target="_blank" hotrep="hp.footer.feedback" class="link">{% trans '蓝鲸智云工作台' %}</a>
|<a class="follow-us" href="###">{% trans '关注我们' %}
<span class="qr-box">
<span class="qr">
<img src="{{STATIC_URL}}img/logo_ce/qr.png">
<span class="qr-caret"></span>
</span>
</span>
</a>
</p>
<p>Copyright © 2012-{{NOW.year}} Tencent BlueKing. All Rights Reserved.</p>
<p>蓝鲸智云 版权所有</p>
</footer>
</div>
<!-- 查看用户协议 -->
{% include "account/agreement.part" %}
<!-- 浏览器验证 -->
<div class="error-message-content is-chrome">
<span>{% trans '您的浏览器非Chrome,建议您使用最新版本的Chrome浏览,以保证最好的体验效果' %}</span><i class="bk-icon icon-close-circle-shape" id="close-chrome"></i>
</div>
</body>
<!-- js 国际化 -->
<script type="text/javascript" src="{{SITE_URL}}jsi18n/i18n/"></script>
<script src="{{STATIC_URL}}assets/jquery-1.10.2.min.js"></script>
<script src="{{STATIC_URL}}js_ce/login.{{JS_SUFFIX}}?v={{STATIC_VERSION}}"></script>

</html>

0 comments on commit c95bd5e

Please sign in to comment.