开发者

Do the Shiro tags 'isLoggedIn' and 'authenticated' mean the same thing?

开发者 https://www.devze.com 2023-04-03 09:40 出处:网络
I am just getting started with both Grails and Shiro and I am looking at adding Shiro to an existing project.

I am just getting started with both Grails and Shiro and I am looking at adding Shiro to an existing project.

I am wondering if the Shiro tags isLoggedIn and authenticated mean the same thing (i.e. always produce the same result)?

The Grails Shiro Plugin page seems开发者_开发知识库 to suggest so:

The tags <shiro:isLoggedIn> and <shiro:authenticated> check for an authenticated user, the tag <shiro:user> checks for a known user (authenticated or remembered) and the tag <shiro:remembered> checks only for a remembered user.

But it is hardly an in-depth description and it doesn't explain why they both exist if they are the same.


Yes, they are exactly the same. Here is the source code:

/**
 * This tag only writes its body to the output if the current user
 * is logged in.
 */
 def isLoggedIn = { attrs, body ->
    if (checkAuthenticated()) {
        out << body()
    }
}

/**
 * A synonym for 'isLoggedIn'. This is the same name as used by
 * the standard Shiro tag library.
 */
def authenticated = isLoggedIn
0

精彩评论

暂无评论...
验证码 换一张
取 消