File tree Expand file tree Collapse file tree 2 files changed +10
-14
lines changed Expand file tree Collapse file tree 2 files changed +10
-14
lines changed Original file line number Diff line number Diff line change 1- from django .conf import settings
21from django_otp import user_has_device
32
3+ from django .conf import settings
4+
45
56def user_needs_to_verify_otp (user ):
67 """
7- This method checks if the device verification is required due to imported
8- middleware in the application settings.
9-
10- Return True as default, to maintain the current behavior as specified in the
11- otp middleware.
8+ This method checks if the device verification is required.
129
13- Returns:
14- bool: True if otp verification is required for the user, False otherwise .
10+ Default returns True, to maintain the current behavior as specified in the
11+ otp middleware .
1512 """
16-
1713 if (
1814 "hidp.otp.middleware.OTPRequiredMiddleware"
1915 ) in settings .MIDDLEWARE :
2016 return True
21-
17+
2218 if (
2319 "hidp.otp.middleware.OTPSetupRequiredIfStaffUserMiddleware"
2420 ) in settings .MIDDLEWARE :
2521 return user .is_staff
26-
22+
2723 if (
2824 "hidp.otp.middleware.OTPVerificationRequiredIfConfiguredMiddleware"
2925 ) in settings .MIDDLEWARE :
3026 return user_has_device (user )
31-
27+
3228 return True
Original file line number Diff line number Diff line change 2323 reset_static_tokens ,
2424)
2525from hidp .otp .forms import OTPSetupForm , VerifyStaticTokenForm , VerifyTOTPForm
26- from hidp .rate_limit .decorators import rate_limit_default
2726from hidp .otp .utils import user_needs_to_verify_otp
27+ from hidp .rate_limit .decorators import rate_limit_default
2828
2929from .decorators import otp_exempt
3030from .mailers import (
@@ -210,7 +210,7 @@ def get_context_data(self, **kwargs):
210210 self .backup_device .token_set .values_list ("token" , flat = True )
211211 ),
212212 "back_url" : reverse ("hidp_otp_management:manage" ),
213- "logout_url" : reverse ("hidp_accounts:logout" )
213+ "logout_url" : reverse ("hidp_accounts:logout" )
214214 if user_needs_to_verify_otp (self .request .user ) else None ,
215215 }
216216
You can’t perform that action at this time.
0 commit comments