Created
June 7, 2009 11:58
-
-
Save uehaj/125301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.appengine.api.users.User; | |
import com.google.appengine.api.users.UserService; | |
import com.google.appengine.api.users.UserServiceFactory; | |
class AppEngineTagLib { | |
def ifLoggedIn = { attrs, body -> | |
def userService = UserServiceFactory.getUserService() | |
if (userService.isUserLoggedIn()) { | |
out << body() | |
} | |
} | |
def ifNotLoggedIn = { attrs, body -> | |
def userService = UserServiceFactory.getUserService() | |
if (!userService.isUserLoggedIn()) { | |
out << body() | |
} | |
} | |
def ifAdminLoggedIn = { attrs, body -> | |
def userService = UserServiceFactory.getUserService() | |
if (userService.isUserAdmin()) { | |
out << body() | |
} | |
} | |
def ifAdminNotLoggedIn = { attrs, body -> | |
def userService = UserServiceFactory.getUserService() | |
if (!userService.isUserAdmin()) { | |
out << body() | |
} | |
} | |
def loginUrl = { attrs, body -> | |
def userService = UserServiceFactory.getUserService() | |
out << userService.createLoginURL(request.getRequestURI()) | |
} | |
def logoutUrl = { attrs, body -> | |
def userService = UserServiceFactory.getUserService() | |
out << userService.createLogoutURL(request.getRequestURI()) | |
} | |
def userNickname = { attrs, body -> | |
def userService = UserServiceFactory.getUserService() | |
def user = userService.getCurrentUser() | |
out << user.getNickname() | |
} | |
def userAuthDomain = { attrs, body -> | |
def userService = UserServiceFactory.getUserService() | |
def user = userService.getCurrentUser() | |
out << user.getAuthDomain() | |
} | |
def userEmail = { attrs, body -> | |
def userService = UserServiceFactory.getUserService() | |
def user = userService.getCurrentUser() | |
out << user.getEmail() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment