Pages

Showing posts with label Beginning Grails Groovy and Griffon. Show all posts
Showing posts with label Beginning Grails Groovy and Griffon. Show all posts

Sunday, February 1, 2015

Beginning Grails, Groovy and Griffon security filter problem.

When i implemented a security filter in my collab-todo app, the only page the filters allowed an unregistered user to view had no styles. Turns out that the assets path was also blocked by the filter.

Thanks to Joshua Moore for answering my question.

The problem is that:
because in recent versions of Grails (2.3+) assets are served up by the asset pipeline plugin from the /assets/**URL.
So the filter should be

securityFilters(controller:'*', action:'*', uriExclude: '/assets/**'){}

instead of just

securityFilters(controller:'*', action:'*'){} 

Thursday, January 29, 2015

Beginning Grails, Groovy and Griffon, error #1

Just found an error in the book. When you create a filter, the author suggests you to copy this code block to your app:

if (session?.user?.id != params?.id) {
flash.message = "You can only modify yourself!"
redirect(controller:"user", action: "index")
return false

}

But actually the params.id is a String and the session.user.id is a Long type, so this condition turns out to be executed every time, even when both values are 2, for example.

The working code would be like this:

if (session?.user?.id?.toInteger() != params?.id?.toInteger()) {
flash.message = "You can only modify yourself!"
redirect(controller:"user", action: "index")
return false

}