Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
server: fix 500 for unauthed get of shots page without shots
Browse files Browse the repository at this point in the history
e.g. from a private window
  • Loading branch information
Greg Guthe committed Aug 28, 2017
1 parent 53ac521 commit 08af2d2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/src/pages/shotindex/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions server/src/pages/shotindex/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ class Body extends React.Component {
return this.renderShotsLoading();
}
let children = [];
for (let shot of this.props.shots) {
children.push(<Card shot={shot} downloadUrl={this.props.downloadUrls[shot.id]} abTests={this.props.abTests} clipUrl={shot.urlDisplay} isOwner={this.props.isOwner} staticLink={this.props.staticLink} isExtInstalled={this.props.isExtInstalled} key={shot.id} />);
if (this.props.shots && this.props.shots.length) {
for (let shot of this.props.shots) {
children.push(<Card shot={shot} downloadUrl={this.props.downloadUrls[shot.id]} abTests={this.props.abTests} clipUrl={shot.urlDisplay} isOwner={this.props.isOwner} staticLink={this.props.staticLink} isExtInstalled={this.props.isExtInstalled} key={shot.id} />);
}
}

if (children.length === 0) {
Expand Down
4 changes: 2 additions & 2 deletions test/server/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down

0 comments on commit 08af2d2

Please sign in to comment.