show Web user page even when direct is False

not other protocols though
pull/799/head
Ryan Barrett 2024-01-22 13:12:20 -08:00
rodzic 86079c3684
commit 907e6e7aeb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 13 dodań i 11 usunięć

Wyświetl plik

@ -79,15 +79,15 @@ def load_user(protocol, id):
elif user and id != user.key.id(): # use_instead redirect
error('', status=302, location=user.user_page_path())
if not user or not user.direct:
# TODO: switch back to USER_NOT_FOUND_HTML
# not easy via exception/abort because this uses Werkzeug's built in
# NotFound exception subclass, and we'd need to make it implement
# get_body to return arbitrary HTML.
error(f'{protocol} user {id} not found', status=404)
if user and (user.direct or protocol == 'web'):
assert not user.use_instead
return user
assert not user.use_instead
return user
# TODO: switch back to USER_NOT_FOUND_HTML
# not easy via exception/abort because this uses Werkzeug's built in
# NotFound exception subclass, and we'd need to make it implement
# get_body to return arbitrary HTML.
error(f'{protocol} user {id} not found', status=404)
@app.route('/')

Wyświetl plik

@ -98,9 +98,11 @@ class PagesTest(TestCase):
self.assert_equals(404, got.status_code)
def test_user_not_direct(self):
self.user.direct = False
self.user.put()
got = self.client.get('/web/user.com')
fake = self.make_user('fake:foo', cls=Fake)
fake.direct = False
fake.put()
got = self.client.get('/fake/fake:foo')
self.assert_equals(404, got.status_code)
def test_user_opted_out(self):