feat: 支持修改忘记密码重置密码的连接 (#5700)

perf: 优化代码暗示

Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
fit2bot
2021-03-10 11:21:12 +08:00
committed by GitHub
parent 81170b4b7b
commit 7b2f813e7f
10 changed files with 122 additions and 104 deletions

View File

@@ -163,7 +163,7 @@
{% endif %}
</div>
<div class="col-md-6">
<a id="forgot_password" href="{% url 'authentication:forgot-password' %}" style="float: right">
<a id="forgot_password" href="{{ forgot_password_url }}" style="float: right">
<small>{% trans 'Forgot password' %}?</small>
</a>
</div>

View File

@@ -100,11 +100,17 @@ class UserLoginView(mixins.AuthMixin, FormView):
self.request.session[RSA_PRIVATE_KEY] = rsa_private_key
self.request.session[RSA_PUBLIC_KEY] = rsa_public_key
forgot_password_url = reverse('authentication:forgot-password')
has_other_auth_backend = settings.AUTHENTICATION_BACKENDS[0] != settings.AUTH_BACKEND_MODEL
if has_other_auth_backend and settings.FORGOT_PASSWORD_URL:
forgot_password_url = settings.FORGOT_PASSWORD_URL
context = {
'demo_mode': os.environ.get("DEMO_MODE"),
'AUTH_OPENID': settings.AUTH_OPENID,
'AUTH_CAS': settings.AUTH_CAS,
'rsa_public_key': rsa_public_key,
'forgot_password_url': forgot_password_url
}
kwargs.update(context)
return super().get_context_data(**kwargs)