Skip to content

Commit

Permalink
Hide generate backup tokens button when enabling 2FA
Browse files Browse the repository at this point in the history
  • Loading branch information
zuhdil committed Jul 9, 2024
1 parent a583293 commit c2d6f3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions akvo/rsr/views/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,8 @@ def get_context_data(self, form, **kwargs):

def get_success_url(self):
next_url = self.get_redirect_url()
success_url = reverse(self.success_url)
return f"{success_url}?next={next_url}" if next_url else success_url
success_url = f"{reverse(self.success_url)}?setup=1"
return f"{success_url}&next={next_url}" if next_url else success_url

def done(self, form_list, **kwargs):
response = super().done(form_list, **kwargs)
Expand Down Expand Up @@ -469,7 +469,11 @@ def form_valid(self, form):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
next_url = self.get_redirect_url()
context.update({"next_url": next_url})
is_setup = self.request.GET.get("setup", "")
context.update({
"next_url": next_url,
"show_generate_button": False if is_setup else True,
})
return context

# Copied from django.contrib.auth.views.LoginView (Branch: stable/1.11.x)
Expand Down
2 changes: 2 additions & 0 deletions akvo/templates/two_factor/core/backup_tokens.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ <h2>{% block title %}{% trans "Backup Tokens" %}{% endblock %}</h1>
{% else %}
<a id="setup-done" href="/my-rsr/my-details/" class="pull-right btn btn-link">{% trans "Back to Account Security" %}</a>
{% endif %}
{% if show_generate_button %}
<button class="btn btn-primary" type="submit">{% trans "Generate Tokens" %}</button>
{% endif %}
</form>

</div>
Expand Down

0 comments on commit c2d6f3f

Please sign in to comment.