Skip to content

Commit

Permalink
Add exception for redirect to marketing consent (#284)
Browse files Browse the repository at this point in the history
* Add exception for redirect to marketing consent

during login the process can halt because the user is redirected to a marketing constent page.
Without catching this condition a KeyError Location is raised because it's the final page but doesn't start with `myskoda://`.

---------

Co-authored-by: Jonas Seydel <[email protected]>
  • Loading branch information
Thor77 and Jonas Seydel authored Dec 16, 2024
1 parent fd45e77 commit 03d373f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions myskoda/auth/authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ async def _enter_password(self, csrf: CSRFState) -> IDKAuthorizationCode:
while not location.startswith("myskoda://"):
if "terms-and-conditions" in location:
raise TermsAndConditionsError(location)
if "consent/marketing" in location:
raise MarketingConsentError(location)
async with self.session.get(location, allow_redirects=False) as response:
location = response.headers["Location"]
codes = location.replace("myskoda://redirect/login/#", "")
Expand Down Expand Up @@ -324,3 +326,6 @@ class AuthorizationFailedError(Exception):

class TermsAndConditionsError(Exception):
"""Redirect to Terms and Conditions was encountered."""

class MarketingConsentError(Exception):
"""Redirect to Marketing Consent encountered."""

0 comments on commit 03d373f

Please sign in to comment.