Tag [roles] does not exist. No tag library found for namespace: sec
-
24-12-2019 - |
Question
Currently have this:
<sec:ifLoggedIn>
<sec:username/><br/>
<sec:roles/><br/>
<g:link controller="logout" action="index">Logout</g:link>
</sec:ifLoggedIn>
<sec:ifNotLoggedIn>
<h1>Who are you?</h1><br/>
<g:link controller="login" action="auth">LOGIN</g:link>
</sec:ifNotLoggedIn>
Which gives the error:
Tag [roles] does not exist. No tag library found for namespace: sec
However when I remove <sec:roles/><br/>
it works fine. Why is this? This is only a problem in production, on intellij everything is great.
La solution
No tag roles
exists in spring security core plugin. If you want to show user roles in the view then you can create your own tag.
class TestTagLib {
static final namespace = 'myTag'
def springSecurityService
def userAuthorities = { attrs ->
out << springSecurityService.principal.authorities
//or out << springSecurityService.authentication.authorities
}
}
and use it in you view as
<myTag:userAuthorities/>
Autres conseils
According to the documentation for the spring security core Grails plugin, there is no tag "roles". That's why it errors. Intellij likely just ignores this tag completely.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow