Skip to content

Commit

Permalink
Fix test snafu
Browse files Browse the repository at this point in the history
  • Loading branch information
rjp committed Dec 8, 2024
1 parent 727b3cf commit 5adc9ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def test_extract_active_user_app(sample_config):
assert app.base_url == 'https://bar.social'
assert app.client_id == 'ghi'
assert app.client_secret == 'jkl'
assert app.redirect_uri == 'urn:ietf:wg:oauth:2.0:oob'


def test_extract_active_when_no_active_user(sample_config):
Expand Down
7 changes: 7 additions & 0 deletions toot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def extract_user_app(config, user_id: str):
return None, None

app_data = config['apps'][instance]

# Handle a missing `redirect_uri`
if 'redirect_uri' not in app_data:
app_data['redirect_uri'] = 'urn:ietf:wg:oauth:2.0:oob'

return User(**user_data), App(**app_data)


Expand Down Expand Up @@ -97,6 +102,8 @@ def load_app(instance: str, redirect_uri: str) -> Optional[App]:
# have worked with OOB and there's no need for a `redirect_uri` update. Maybe?
if a.redirect_uri == "":
a.redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
if a.redirect_uri != redirect_uri:
a.redirect_uri = redirect_uri
return a


Expand Down

0 comments on commit 5adc9ea

Please sign in to comment.