If not logged in, go home when clicking GOV.UK

It’s a bit of a weird experience to be taken to the sign in screen when
you click GOV.UK in the header. It’s doubly weird if you take the tour
before creating an account, and at the end of the tour you get prompted
to sign in.

This commit adds some extra logic to take you to the homepage instead,
which I think is more what you’d expect.
This commit is contained in:
Chris Hill-Scott
2016-04-24 09:46:44 +01:00
parent 7b540fe10b
commit ba7d9cd486
2 changed files with 5 additions and 2 deletions

View File

@@ -16,8 +16,11 @@ def choose_service():
@main.route("/services-or-dashboard")
@login_required
def show_all_services_or_dashboard():
if not current_user.is_authenticated():
return redirect(url_for('.index'))
services = service_api_client.get_services({'user_id': current_user.id})['data']
if 1 == len(services):

View File

@@ -59,7 +59,7 @@ def test_should_redirect_if_not_logged_in(app_):
with app_.test_client() as client:
response = client.get(url_for('main.show_all_services_or_dashboard'))
assert response.status_code == 302
assert url_for('main.sign_in', _external=True) in response.location
assert url_for('main.index', _external=True) in response.location
def test_should_show_all_services_for_platform_admin_user(app_,