Reputation: 1683
I've written some code that checks to see if the user is logged in as an admin or not to limit who can make changes to other user's permissions, but the if tag is never true. I've made sure the correct data is there by echoing it out but nothing I've found so far has given me a solution.
<g:if test="${session.userPermissions == 'Administrator'}">
<g:select id="permissions" name="permissions" from="${userInstance.constraints.permissions.inList}" value="${userInstance.permissions}" ></g:select>
</g:if>
<g:else>
${userInstance.permissions}
</g:else>
Upvotes: 2
Views: 17212
Reputation: 10325
try "java" String ways :D
<g:if test="${session.userPermissions.equals('Administrator')}">
....
</g:if>
Upvotes: 8
Reputation: 1683
It ends up a groovy thing-
I used a criteria to get the user's login information. The criteria returns a list of user variables. I was setting session.userPermissions = user.permissions
In groovy you can access every list element's properties and retrieve them as a new list (example below). This was giving me the list variables in my session. It's a really cool feature, but not one you like to find on accident like this.
groovy> def demo = []
groovy> demo[0] = [a:1, b:2]
groovy> demo[1] = [a:3, b:4]
groovy> demo[2] = [a:5, b:6]
groovy> demo.a
Result: [1, 3, 5]
Upvotes: 1