views:

124

answers:

1

I'm building a web application with Grails, using the Acegi/Spring Security plugin.

I want to only show the 'Edit' link if the page is showing the details of the currently logged in user.

For example, the logged in user with id = 44 is viewing the page 'localhost:8080/app/user/show/44'

I've tried the following but it's not working. Any ideas on how to make this work, or is there some really simple way I've missed?

<g:isLoggedIn>
    <g:if test="${person.id == loggedInUserInfo(field='id')}">
        <g:link controller="user" action="edit" id="${person.id}">Edit</g:link>
    </g:if>
</g:isLoggedIn>
+2  A: 

i don't know if it is just a typo in this question but loggedInUserInfo should be called with a map.

you make an assignment in the method call, which results in giving just the value 'id' to loggedInUserInfo

instead of field='id' it should say field : 'id'

<g:isLoggedIn>
    <g:if test="${person.id == loggedInUserInfo(field : 'id')}">
        <g:link controller="user" action="edit" id="${person.id}">Edit</g:link>
    </g:if>
</g:isLoggedIn>
squiddle