tags:

views:

37

answers:

1

I'm brand new to acegi and relatively new to Grails.

I just followed the tutorial to set up a new role and a new user. Every time I saved the user (with a role checked), it saved the user information fine, but not the role associated with the user.

I finally dug into the controller code that was generated, and noticed this:

private void addRoles(person) {
 for (String key in params.keySet()) {
  if (key.contains('ROLE') && 'on' == params.get(key)) {
   Authority.findByAuthority(key).addToPeople(person)
  }
 }
}

So to be sure I was interpreting it correctly, I added the word ROLE to my authorties, and it worked like a charm. Am I missing something obvious, is this a bug, or.......?

The examples showed simple role names like "user" or "manager".

A: 

All of your Acegi authorities should be ROLE_something. It is possible to change the default prefix configuration from ROLE_ to something else: http://www.acegisecurity.org/acegi-security/apidocs/org/acegisecurity/runas/RunAsManagerImpl.html

Sean A.O. Harney