Skip to content

Commit

Permalink
[breaking] sessions - Returning 404 on GET /sessions/current when no …
Browse files Browse the repository at this point in the history
…session is defined on current request
  • Loading branch information
fcamblor committed Aug 21, 2017
1 parent 46f8b58 commit 8c14dff
Showing 1 changed file with 8 additions and 4 deletions.
Expand Up @@ -61,11 +61,15 @@ public Session authenticate(Map session) {
}

@GET("/sessions/current")
public Session currentSession() {
String sessionKey = RestxSession.current().get(String.class, Session.SESSION_DEF_KEY).get();
RestxPrincipal principal = RestxSession.current().getPrincipal().get();
public Optional<Session> currentSession() {
Optional<String> sessionKey = RestxSession.current().get(String.class, Session.SESSION_DEF_KEY);
Optional<? extends RestxPrincipal> principal = RestxSession.current().getPrincipal();

return new Session(sessionKey, principal);
if(!sessionKey.isPresent() || !principal.isPresent()) {
return Optional.absent();
}

return Optional.of(new Session(sessionKey.get(), principal.get()));
}

@PermitAll
Expand Down

0 comments on commit 8c14dff

Please sign in to comment.