From 6d04702dadc16ac7231548c1332c5c9ecc5ae907 Mon Sep 17 00:00:00 2001 From: Patrick Smith Date: Tue, 28 Aug 2018 09:33:18 -0400 Subject: [PATCH] Handle unauthorized error in workspace context Previously, an `UnauthorizedError` raised when attempting to view an workspace that you are not authorized for would show an error instead of the "not found" page since a second `UnauthorizedError` would be raised evaluating the context for the "not found" page. --- atst/routes/workspaces.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/atst/routes/workspaces.py b/atst/routes/workspaces.py index 9f8365ef..64faac94 100644 --- a/atst/routes/workspaces.py +++ b/atst/routes/workspaces.py @@ -7,6 +7,7 @@ from flask import ( url_for, ) +from atst.domain.exceptions import UnauthorizedError from atst.domain.workspaces import Workspaces from atst.domain.projects import Projects from atst.forms.new_project import NewProjectForm @@ -19,9 +20,12 @@ bp = Blueprint("workspaces", __name__) def workspace(): workspace = None if "workspace_id" in http_request.view_args: - workspace = Workspaces.get( - g.current_user, http_request.view_args["workspace_id"] - ) + try: + workspace = Workspaces.get( + g.current_user, http_request.view_args["workspace_id"] + ) + except UnauthorizedError: + pass return {"workspace": workspace}