Skip to content

Commit 3bdd645

Browse files
Ruff fix
1 parent b894e7e commit 3bdd645

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

packages/hidp/hidp/otp/utils.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1-
from django.conf import settings
21
from django_otp import user_has_device
32

3+
from django.conf import settings
4+
45

56
def 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

packages/hidp/hidp/otp/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
reset_static_tokens,
2424
)
2525
from hidp.otp.forms import OTPSetupForm, VerifyStaticTokenForm, VerifyTOTPForm
26-
from hidp.rate_limit.decorators import rate_limit_default
2726
from hidp.otp.utils import user_needs_to_verify_otp
27+
from hidp.rate_limit.decorators import rate_limit_default
2828

2929
from .decorators import otp_exempt
3030
from .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

0 commit comments

Comments
 (0)