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.
This commit is contained in:
parent
1fb43a9fd6
commit
6d04702dad
@ -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}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user