Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. try
  2. {
  3. User user = currentUser(); //Throws UnauthenticatedException if not logged in.
  4. //Do stuff with the user.
  5. }
  6. catch (UnauthenticatedException e)
  7. {
  8. //Do nothing, it's perfectly fine to not do the above code
  9. //if the user isn't logged in.
  10. }
  11.  
  12. currentUser.isLogged()
  13.  
  14. public void valid() throws UnauthenticatedException{
  15. User user = currentUser(); //Throws UnauthenticatedException if not logged in.
  16. }
  17.  
  18. public Optional<User> authenticate(){
  19.  
  20. User user = null;
  21. try {
  22. user = currentUser();
  23. }
  24. catch (UnauthenticatedException e){
  25. }
  26.  
  27. return Optional.ofNullable(user);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement