|  | 
| 1 |  | -from django.apps.registry import apps | 
| 2 | 1 | from django.conf import settings | 
| 3 | 2 | from django.contrib.auth.decorators import login_required | 
| 4 | 3 | from django.shortcuts import redirect, resolve_url | 
| @@ -30,24 +29,22 @@ class ProfileView(TemplateView): | 
| 30 | 29 |     template_name = 'two_factor/profile/profile.html' | 
| 31 | 30 | 
 | 
| 32 | 31 |     def get_context_data(self, **kwargs): | 
|  | 32 | +        user = self.request.user | 
|  | 33 | + | 
| 33 | 34 |         try: | 
| 34 |  | -            backup_tokens = self.request.user.staticdevice_set.all()[0].token_set.count() | 
|  | 35 | +            backup_tokens = user.staticdevice_set.all()[0].token_set.count() | 
| 35 | 36 | 
 | 
| 36 | 37 |         except Exception: | 
| 37 | 38 |             backup_tokens = 0 | 
| 38 | 39 | 
 | 
| 39 | 40 |         context = { | 
| 40 |  | -            'default_device': default_device(self.request.user), | 
| 41 |  | -            'default_device_type': default_device(self.request.user).__class__.__name__, | 
|  | 41 | +            'default_device': default_device(user), | 
|  | 42 | +            'default_device_type': default_device(user).__class__.__name__, | 
| 42 | 43 |             'backup_tokens': backup_tokens, | 
|  | 44 | +            'backup_phones': backup_phones(user), | 
|  | 45 | +            'available_phone_methods': get_available_phone_methods(), | 
| 43 | 46 |         } | 
| 44 | 47 | 
 | 
| 45 |  | -        if (apps.is_installed('two_factor.plugins.phonenumber')): | 
| 46 |  | -            context.update({ | 
| 47 |  | -                'backup_phones': backup_phones(self.request.user), | 
| 48 |  | -                'available_phone_methods': get_available_phone_methods(), | 
| 49 |  | -            }) | 
| 50 |  | - | 
| 51 | 48 |         return context | 
| 52 | 49 | 
 | 
| 53 | 50 | 
 | 
|  | 
0 commit comments