Commit da63d852 by Kálmán Viktor

dashboard: disable overwriting existing 2fa codes

parent 269e1b6c
Pipeline #200 passed with stage
in 0 seconds
......@@ -583,6 +583,14 @@ class EnableTwoFactorView(LoginRequiredMixin, UpdateView):
template_name = "dashboard/enable-two-factor.html"
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 al"
"ready enabled for your account."))
return redirect(reverse("dashboard.index"))
return super().dispatch(*args, **kwargs)
def get_object(self, queryset=None):
if self.request.user.is_anonymous():
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