Skip to content

Commit

Permalink
Fix a bug in authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
ttuovinen committed Feb 7, 2024
1 parent 89d92d3 commit c3116e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions api/ekirjasto_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ def local_patron_lookup(

def ekirjasto_authenticate(
self, _db: Session, ekirjasto_token: str
) -> tuple[PatronData | Patron | ProblemDetail | None, bool]:
) -> tuple[Patron | ProblemDetail | None, bool]:
"""Authenticate patron with remote ekirjasto API and if necessary,
create authenticated patron if not in database.
Expand All @@ -627,10 +627,11 @@ def ekirjasto_authenticate(
if isinstance(auth_result, PatronData):
# We didn't find the patron, but authentication to external truth was
# successful, so we create a new patron with the information we have.
patron, is_new = auth_result.get_or_create_patron(
new_patron, is_new = auth_result.get_or_create_patron(
_db, self.library_id, analytics=self.analytics
)
patron.last_external_sync = utc_now()
new_patron.last_external_sync = utc_now()
return new_patron, is_new

return auth_result, is_new

Expand Down
2 changes: 1 addition & 1 deletion tests/api/finland/test_ekirjasto.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ def test_authenticated_patron_delegate_token_expired(

assert patron is None

def test_authenticated_patron_ekirjasto_token_invald(
def test_authenticated_patron_ekirjasto_token_invalid(
self,
create_provider: Callable[..., MockEkirjastoAuthenticationAPI],
controller_fixture: ControllerFixture,
Expand Down

0 comments on commit c3116e3

Please sign in to comment.