Permalink
Browse files

[breaking] sessions - Returning 404 on GET /sessions/current when no …

…session is defined on current request
  • Loading branch information...
fcamblor committed Aug 21, 2017
1 parent 46f8b58 commit 8c14dff707cdba2c6f00f11e66be3b10a79726fe
Showing with 8 additions and 4 deletions.
  1. +8 −4 restx-security-basic/src/main/java/restx/security/SessionResource.java
@@ -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

0 comments on commit 8c14dff

Please sign in to comment.