From 08af2d2846576aa14ca61d1cbb9bd1909f50282f Mon Sep 17 00:00:00 2001 From: Greg Guthe Date: Mon, 28 Aug 2017 13:30:07 -0400 Subject: [PATCH] server: fix 500 for unauthed get of shots page without shots e.g. from a private window --- server/src/pages/shotindex/model.js | 2 +- server/src/pages/shotindex/view.js | 6 ++++-- test/server/test_responses.py | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/server/src/pages/shotindex/model.js b/server/src/pages/shotindex/model.js index 1056a87b3d..f77314c075 100644 --- a/server/src/pages/shotindex/model.js +++ b/server/src/pages/shotindex/model.js @@ -28,7 +28,7 @@ exports.createModel = function(req) { image.url = createProxyUrl(req, image.url); } } - if (shots !== null) { + if (shots !== null && shots !== undefined) { shots = shots.map((shot) => ({id: shot.id, json: shot.asRecallJson()})); } let jsonModel = Object.assign( diff --git a/server/src/pages/shotindex/view.js b/server/src/pages/shotindex/view.js index fa02bc9cab..3f5b553a57 100644 --- a/server/src/pages/shotindex/view.js +++ b/server/src/pages/shotindex/view.js @@ -52,8 +52,10 @@ class Body extends React.Component { return this.renderShotsLoading(); } let children = []; - for (let shot of this.props.shots) { - children.push(); + if (this.props.shots && this.props.shots.length) { + for (let shot of this.props.shots) { + children.push(); + } } if (children.length === 0) { diff --git a/test/server/test_responses.py b/test/server/test_responses.py index 762b9701dc..20e0851d07 100644 --- a/test/server/test_responses.py +++ b/test/server/test_responses.py @@ -115,10 +115,10 @@ def test_my_shots_page(): shot_page = user.read_my_shots() + # e.g. direct navigation to /shots in private window unauthed_user = ScreenshotsClient() response = unauthed_user.get_uri("/shots") - if response.status_code != 500: # TODO: fix direct navigation to /shots in private window - response.raise_for_status() + response.raise_for_status() if __name__ == "__main__":