diff --git a/seahub/api2/endpoints/admin/two_factor_auth.py b/seahub/api2/endpoints/admin/two_factor_auth.py index 0bc2ad7e97..8e357c62fd 100644 --- a/seahub/api2/endpoints/admin/two_factor_auth.py +++ b/seahub/api2/endpoints/admin/two_factor_auth.py @@ -9,7 +9,7 @@ from seahub.api2.base import APIView from seahub.api2.throttling import UserRateThrottle from seahub.api2.utils import json_response, api_error from seahub.api2.authentication import TokenAuthentication -from seahub.utils.two_factor_auth import has_two_factor_auth, two_factor_auth_enabled +from seahub.utils.two_factor_auth import two_factor_auth_enabled class TwoFactorAuthView(APIView): @@ -22,14 +22,14 @@ class TwoFactorAuthView(APIView): error_msg = "email can not be empty" return api_error(status.HTTP_400_BAD_REQUEST, error_msg) try: - _user = User.objects.get(email=email) + user = User.objects.get(email=email) except User.DoesNotExist: error_msg = "User %s not found" % email return api_error(status.HTTP_400_BAD_REQUEST, error_msg) from seahub_extra.two_factor import devices_for_user - devices = devices_for_user(_user) + devices = devices_for_user(user) if devices: for device in devices: device.delete() - return Response({'success':True}, status=status.HTTP_200_OK) + return Response({'success': True}, status=status.HTTP_200_OK) diff --git a/seahub/views/sysadmin.py b/seahub/views/sysadmin.py index bb958303d9..fe00b6c964 100644 --- a/seahub/views/sysadmin.py +++ b/seahub/views/sysadmin.py @@ -675,12 +675,12 @@ def user_info(request, email): else: g.role = _('Member') - _default_device = False - _has_two_factor_auth = has_two_factor_auth() - if _has_two_factor_auth: + default_device = False + bool_has_two_factor_auth = has_two_factor_auth() + if bool_has_two_factor_auth: from seahub_extra.two_factor.utils import default_device - _user = User.objects.get(email=email) - _default_device = default_device(_user) + user = User.objects.get(email=email) + default_device = default_device(user) return render_to_response( 'sysadmin/userinfo.html', { @@ -695,8 +695,8 @@ def user_info(request, email): 'user_shared_links': user_shared_links, 'enable_sys_admin_view_repo': ENABLE_SYS_ADMIN_VIEW_REPO, 'personal_groups': personal_groups, - 'two_factor_auth_enabled': _has_two_factor_auth, - 'default_device': _default_device, + 'two_factor_auth_enabled': bool_has_two_factor_auth, + 'default_device': default_device, }, context_instance=RequestContext(request)) @login_required_ajax