문제

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.

도움이 되었습니까?

해결책

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/>

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top