-
-
Couldn't load subscription status.
- Fork 461
Description
Expected Behavior
Users should be given an option to setup more methods instead of only primary method.
Current Behavior
When user setup for example yubikey, then in two_factor view sees "Primary method: Use your Yubikey device" and setup for another methods is not possible.
In setup this is clearly visible that this is intentional disabled:
django-two-factor-auth/two_factor/views/core.py
Lines 486 to 492 in 95255bb
| def get(self, request, *args, **kwargs): | |
| """ | |
| Start the setup wizard. Redirect if already enabled. | |
| """ | |
| if default_device(self.request.user): | |
| return redirect(self.get_success_url()) | |
| return super().get(request, *args, **kwargs) |
However, in login view, many different methods are handled if they exist, for example created in custom form or via admin panel
django-two-factor-auth/two_factor/views/core.py
Lines 359 to 367 in 95255bb
| def get_context_data(self, form, **kwargs): | |
| """ | |
| Adds user's default and backup OTP devices to the context. | |
| """ | |
| context = super().get_context_data(form, **kwargs) | |
| if self.steps.current == self.TOKEN_STEP: | |
| device = self.get_device() | |
| context['device'] = device | |
| context['other_devices'] = self.get_other_devices(device) |
Possible Solution
Allow users to setup 2fa many times. It's already handled in login so that's for free and could be supported in account and setup views with relatively moderate code changes. Note that I am not sure why is it not a case, maybe there are some non trivial things to consider or breaking changes like that are not acceptable for some reason.
Context
For yubikey setup for eaxmple it totally makes sense and is popular to have 2 or more different keys for example one dedicated to pc, second to laptop and alternatively some backup one.
