throws RedbackServiceException;
/**
- * simply check if current user has an http session opened with authz passed
+ * simply check if current user has an http session opened with authz passed and return user data
* @since 1.4
*/
@Path( "isLogged" )
@GET
- @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization( noRestriction = true )
- Boolean isLogged()
+ User isLogged()
throws RedbackServiceException;
/**
* @author Olivier Lamy
* @since 1.3
*/
-@Service("loginService#rest")
+@Service( "loginService#rest" )
public class DefaultLoginService
implements LoginService
{
@Inject
public DefaultLoginService( SecuritySystem securitySystem,
- @Named("httpAuthenticator#basic") HttpAuthenticator httpAuthenticator )
+ @Named( "httpAuthenticator#basic" ) HttpAuthenticator httpAuthenticator )
{
this.securitySystem = securitySystem;
this.httpAuthenticator = httpAuthenticator;
}
- public Boolean isLogged()
+ public User isLogged()
throws RedbackServiceException
{
- Boolean isLogged = httpAuthenticator.getSecuritySession( httpServletRequest.getSession( true ) ) != null;
+ SecuritySession securitySession = httpAuthenticator.getSecuritySession( httpServletRequest.getSession( true ) );
+ Boolean isLogged = securitySession != null;
log.debug( "isLogged {}", isLogged );
- return isLogged;
+ return isLogged ? buildRestUser( securitySession.getUser() ) : null;
}
public Boolean logout()