package edu.asu.scrapbook.digital.util;

import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

import edu.asu.scrapbook.digital.dao.UserDAO;
import edu.asu.scrapbook.digital.dao.UserDAOFactory;

public class UserUtil {
	public static String getRequestUsername() {
		UserService userService = UserServiceFactory.getUserService();
		return userService.getCurrentUser().getEmail();
	}
	
	public static boolean userExists(String username) throws Exception {
		UserDAO dao = UserDAOFactory.getInstance();
		return dao.findById(username) != null;
	}
}

@@ -32,24 +32,69 @@
 al.util;%0D%0A%0D%0A
+import com.google.appengine.api.users.User;%0D%0A
 import com.g
@@ -436,22 +436,31 @@
 e();%0D%0A%09%09
-return
+User authUser =
  userSer
@@ -480,16 +480,57 @@
 ntUser()
+;%0D%0A%09%09return (authUser != null) ? authUser
 .getEmai
@@ -532,16 +532,23 @@
 tEmail()
+ : null
 ;%0D%0A%09%7D%0D%0A%09

Add null check in case user isn't logged in