Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try
- {
- User user = currentUser(); //Throws UnauthenticatedException if not logged in.
- //Do stuff with the user.
- }
- catch (UnauthenticatedException e)
- {
- //Do nothing, it's perfectly fine to not do the above code
- //if the user isn't logged in.
- }
- currentUser.isLogged()
- public void valid() throws UnauthenticatedException{
- User user = currentUser(); //Throws UnauthenticatedException if not logged in.
- }
- public Optional<User> authenticate(){
- User user = null;
- try {
- user = currentUser();
- }
- catch (UnauthenticatedException e){
- }
- return Optional.ofNullable(user);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement