Skip to content

Commit e4514f5

Browse files
robkooperlmarini
andauthored
Fix NoSuchElementException for anonymous users in spaces listing and miniList templates (#460)
- Add user existence checks before accessing user properties in app/views/spaces/listSpaces.scala.html and app/views/spaces/miniList.scala.html - Update CHANGELOG.md with details of the fix in Unreleased section Co-authored-by: Luigi Marini <[email protected]>
1 parent 649eaca commit e4514f5

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8-
## [Unreleased]
8+
## Unreleased
99

1010
### Fixed
11+
- Fixed `NoSuchElementException` in spaces listing page when user is not defined. The error occurred when calling `user.get.id` on an undefined user in the spaces ownership dropdown. Added proper user existence checks in `listSpaces.scala.html` and `miniList.scala.html` templates.
1112
- Removed refrences to repo.typesafe.com from sbt-launch.jar and build.scala
1213

1314
### Removed

app/views/spaces/listSpaces.scala.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ <h1>@title</h1>
4747
case (_, _) => {}
4848
}
4949
}
50-
<div class="btn-group btn-group-sm" id="spacesOwnership-displayed-dropdown">
51-
<select id="spacesOwnership" class="form-control" onchange="getSpaceType('@user.get.id')">
52-
<option value="1">Joined Spaces</option>
53-
<option value="2">My Spaces</option>
54-
<option value="3">All Spaces</option>
55-
</select>
56-
</div>
50+
@if(user.isDefined) {
51+
<div class="btn-group btn-group-sm" id="spacesOwnership-displayed-dropdown">
52+
<select id="spacesOwnership" class="form-control" onchange="getSpaceType('@user.get.id')">
53+
<option value="1">Joined Spaces</option>
54+
<option value="2">My Spaces</option>
55+
<option value="3">All Spaces</option>
56+
</select>
57+
</div>
58+
}
5759
<div class="btn-group btn-group-sm" id="number-displayed-dropdown">
5860
<select id="numPageItems" class="form-control" onchange="getValue()">
5961
<option value="12">12</option>

app/views/spaces/miniList.scala.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<div class="text-center">
2424
@if(ownProfile) {
2525
<div>@Messages("home.empty.message", Messages("spaces.title").toLowerCase)</div>
26-
@if(user.get.status != UserStatus.ReadOnly) {
26+
@if(user.isDefined && user.get.status != UserStatus.ReadOnly) {
2727
<div><a class="btn-link" href="@routes.Spaces.newSpace()" title="Create a new @Messages("space.title")">@Messages("create.title", Messages("space.title"))</a></div>
2828
}
2929
} else {

0 commit comments

Comments
 (0)