Browse Source

Update "Change Password" to show messages in panel's footer

pull/456/head
Pēteris Caune 4 years ago
parent
commit
48750ee668
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
2 changed files with 11 additions and 2 deletions
  1. +5
    -1
      hc/accounts/views.py
  2. +6
    -1
      templates/accounts/profile.html

+ 5
- 1
hc/accounts/views.py View File

@ -231,6 +231,10 @@ def profile(request):
if ctx["removed_credential_name"]: if ctx["removed_credential_name"]:
ctx["2fa_status"] = "info" ctx["2fa_status"] = "info"
if request.session.pop("changed_password", False):
ctx["changed_password"] = True
ctx["email_password_status"] = "success"
if request.method == "POST" and "leave_project" in request.POST: if request.method == "POST" and "leave_project" in request.POST:
code = request.POST["code"] code = request.POST["code"]
try: try:
@ -471,7 +475,7 @@ def set_password(request):
# the user doesn't get logged out # the user doesn't get logged out
update_session_auth_hash(request, request.user) update_session_auth_hash(request, request.user)
messages.success(request, "Your password has been set!")
request.session["changed_password"] = True
return redirect("hc-profile") return redirect("hc-profile")
return render(request, "accounts/set_password.html", {}) return render(request, "accounts/set_password.html", {})


+ 6
- 1
templates/accounts/profile.html View File

@ -33,7 +33,7 @@
</div> </div>
<div class="col-sm-9 col-md-6"> <div class="col-sm-9 col-md-6">
<div class="panel panel-default">
<div class="panel panel-{{ email_password_status|default:'default' }}">
<div class="panel-body settings-block"> <div class="panel-body settings-block">
<form method="post"> <form method="post">
{% csrf_token %} {% csrf_token %}
@ -55,6 +55,11 @@
</p> </p>
</form> </form>
</div> </div>
{% if changed_password %}
<div class="panel-footer">
Your new password has been set!
</div>
{% endif %}
</div> </div>
<div class="panel panel-{{ 2fa_status }}"> <div class="panel panel-{{ 2fa_status }}">


Loading…
Cancel
Save