Skip to content

Commit 3b87fee

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

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

.secrets.baseline

Lines changed: 2 additions & 2 deletions
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-04T15:39:38Z"
244244
}

authentication/pipeline/user.py

Lines changed: 4 additions & 2 deletions
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,
@@ -82,7 +81,10 @@ def limit_one_auth_per_backend(strategy, backend, user, uid, **kwargs): # pylin
8281
# if there's at least one social auth and any of them don't match the incoming uid
8382
# we have or are trying to add multiple accounts
8483
if social_auths and any(auth.uid != uid for auth in social_auths):
85-
raise AuthException(backend.name, "Another account is already linked to your MITxOnline account.")
84+
raise AuthException(
85+
backend.name,
86+
"Another account is already linked to your MITxOnline account.",
87+
)
8688

8789
return {}
8890

authentication/pipeline/user_test.py

Lines changed: 11 additions & 5 deletions
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):
@@ -563,4 +567,6 @@ def test_limit_one_auth_per_backend_conflicting_auth(mocker, user):
563567
assert UserSocialAuth.filter(user=user, provider=mock_backend.name).count() == 1
564568

565569
with pytest.raises(AuthException):
566-
user_actions.limit_one_auth_per_backend(backend=mock_backend, user=user, strategy=mock_strategy, uid="non-matching")
570+
user_actions.limit_one_auth_per_backend(
571+
backend=mock_backend, user=user, strategy=mock_strategy, uid="non-matching"
572+
)

0 commit comments

Comments
 (0)