Skip to content

Commit adb7d8c

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent e84020e commit adb7d8c

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

.secrets.baseline

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
"filename": "main/settings.py",
194194
"hashed_secret": "09edaaba587f94f60fbb5cee2234507bcb883cc2",
195195
"is_verified": false,
196-
"line_number": 954
196+
"line_number": 955
197197
}
198198
],
199199
"pants": [
@@ -240,5 +240,5 @@
240240
}
241241
]
242242
},
243-
"generated_at": "2025-01-22T20:35:24Z"
243+
"generated_at": "2025-03-04T18:58:14Z"
244244
}

authentication/pipeline/user.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from social_core.pipeline.partial import partial
1010
from social_django.models import UserSocialAuth
1111

12-
1312
from authentication.exceptions import (
1413
EmailBlockedException,
1514
InvalidPasswordException,
@@ -81,7 +80,10 @@ def limit_one_auth_per_backend(strategy, backend, user, uid, **kwargs): # pylin
8180
# if there's at least one social auth and any of them don't match the incoming uid
8281
# we have or are trying to add multiple accounts
8382
if social_auths and any(auth.uid != uid for auth in social_auths):
84-
raise AuthException(backend.name, "Another account is already linked to your MITxOnline account.")
83+
raise AuthException(
84+
backend.name,
85+
"Another account is already linked to your MITxOnline account.",
86+
)
8587

8688
return {}
8789

authentication/pipeline/user_test.py

+15-6
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
from django.db import IntegrityError
99
from rest_framework import status
1010
from social_core.backends.email import EmailAuth
11-
from social_django.utils import load_backend, load_strategy
1211
from social_core.exceptions import AuthException
1312
from social_django.models import UserSocialAuth
14-
15-
13+
from social_django.utils import load_backend, load_strategy
1614

1715
from authentication.exceptions import (
1816
EmailBlockedException,
@@ -550,7 +548,13 @@ def test_limit_one_auth_per_backend_no_user(mocker):
550548
"""limit_one_auth_per_backend should not error if the user doesn't exist"""
551549
mock_strategy = mocker.Mock()
552550
mock_backend = mocker.Mock()
553-
assert user_actions.limit_one_auth_per_backend(strategy=mock_strategy, backend=mock_backend, user=None, uid=None) == {}
551+
assert (
552+
user_actions.limit_one_auth_per_backend(
553+
strategy=mock_strategy, backend=mock_backend, user=None, uid=None
554+
)
555+
== {}
556+
)
557+
554558

555559
@pytest.mark.django_db
556560
def test_limit_one_auth_per_backend_conflicting_auth(mocker, user):
@@ -560,7 +564,12 @@ def test_limit_one_auth_per_backend_conflicting_auth(mocker, user):
560564
mock_backend.name = "email"
561565
UserSocialAuthFactory.create(user=user, provider=mock_backend.name)
562566

563-
assert UserSocialAuth.objects.filter(user=user, provider=mock_backend.name).count() == 1
567+
assert (
568+
UserSocialAuth.objects.filter(user=user, provider=mock_backend.name).count()
569+
== 1
570+
)
564571

565572
with pytest.raises(AuthException):
566-
user_actions.limit_one_auth_per_backend(backend=mock_backend, user=user, strategy=mock_strategy, uid="non-matching")
573+
user_actions.limit_one_auth_per_backend(
574+
backend=mock_backend, user=user, strategy=mock_strategy, uid="non-matching"
575+
)

0 commit comments

Comments
 (0)