0

我刚刚开始使用 Grails 和 Shiro,我正在考虑将 Shiro 添加到现有项目中。

我想知道 Shiro 标签isLoggedInauthenticated意思是否相同(即总是产生相同的结果)?

Grails Shiro 插件页面似乎是这样建议的:

标记<shiro:isLoggedIn><shiro:authenticated>检查经过身份验证的用户,标记<shiro:user>检查已知用户(经过验证或记住),并且标记<shiro:remembered>仅检查记住的用户。

但这几乎不是一个深入的描述,也没有解释如果它们相同,为什么它们都存在。

4

1 回答 1

1

是的,它们完全相同。 这是源代码

/**
 * 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
于 2011-09-06T12:35:35.507 回答