Commit 2ded5588 by Kálmán Viktor

dashboard: disable overwriting existing 2fa codes

parent 269e1b6c
Pipeline #199 failed with stage
in 0 seconds
...@@ -583,6 +583,14 @@ class EnableTwoFactorView(LoginRequiredMixin, UpdateView): ...@@ -583,6 +583,14 @@ class EnableTwoFactorView(LoginRequiredMixin, UpdateView):
template_name = "dashboard/enable-two-factor.html" template_name = "dashboard/enable-two-factor.html"
success_url = reverse_lazy("dashboard.views.profile-preferences") success_url = reverse_lazy("dashboard.views.profile-preferences")
def dispatch(self, *args, **kwargs):
if self.get_object().two_factor_secret:
messages.info(self.request, _("Two-factor authentication is already"
" enabled for your account."))
return redirect(reverse("dashboard.index"))
return super().dispatch(*args, **kwargs)
def get_object(self, queryset=None): def get_object(self, queryset=None):
if self.request.user.is_anonymous(): if self.request.user.is_anonymous():
raise PermissionDenied raise PermissionDenied
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment