mbknor/faster-groovy-templates — Issue #12: [Deadbolt and fastergt] bug or not compatible together?
Author: Korrawit
Created: 2012-02-21 19:32:06+00:00
State: open

I use Deadbolt and Fastergt module.

I found this problem when I use restrict tag in my view page.

I try to debug in eclipse and found this.

Catch error: ![Alt Text](http://i.imgur.com/sRKJr.jpgm)

Because after deadbolt run to line ```DEADBOLT_HANDLER.beforeRoleCheck();``` it will redirect,if user not logged in.

How to fix this ?

**Error**

```
@69en98853
Internal Server Error (500) for request GET /

Template execution error (In /app/views/Application/index.html around line 0)
Execution error occured in template /app/views/Application/index.html. Exception raised was GTRuntimeException : null.

play.exceptions.TemplateExecutionException
at play.modules.gtengineplugin.GTTemplate.renderGTTemplate(GTTemplate.java:114)
at play.modules.gtengineplugin.GTTemplate.internalGTRender(GTTemplate.java:73)
at play.modules.gtengineplugin.GTTemplate.internalRender(GTTemplate.java:52)
at play.modules.gtengineplugin.GTTemplate.render(GTTemplate.java:124)
at play.mvc.results.RenderTemplate.(RenderTemplate.java:24)
at play.mvc.Controller.renderTemplate(Controller.java:660)
at play.mvc.Controller.renderTemplate(Controller.java:640)
at play.mvc.Controller.render(Controller.java:695)
at controllers.Application.index(Application.java:23)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:548)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
at Invocation.HTTP Request(Play!)
Caused by: play.template2.exceptions.GTRuntimeException
Caused by: play.template2.exceptions.GTRuntimeException
Caused by: play.mvc.results.Redirect
```

**Use Deadbolt in my view page**

```
#{deadbolt.restrict roles:[['Member']]}
this restricts access to this content to role holders with the "foo" role
#{/deadbolt.restrict}
```
**Deadbolt restrict tag**

```
%{
boolean allowAccess = false;
for (int i = 0; !allowAccess && i < _roles.size(); i++)
{
allowAccess = controllers.deadbolt.Deadbolt.hasRoles(_roles.get(i))
}
}%
#{if allowAccess}
#{doBody /}
#{/if}
```

**hasRoles method**

```
public static boolean hasRoles(List roleNames) throws Throwable
{
DEADBOLT_HANDLER.beforeRoleCheck();
RoleHolder roleHolder = getRoleHolder();

return roleHolder != null &&
roleHolder.getRoles() != null &&
hasAllRoles(roleHolder,
roleNames.toArray(new String[roleNames.size()]));
}

```