-
1. Re: user registeration and roles
radu May 2, 2009 9:38 AM (in response to nitm)How about adding a boolean field to your Role entity isDefaultRole?
In your registration bean, you get a list of roles with isDefaultRole = true.
You just have to iterate through results and callidentityManager.grantRole(usernameYouAreTryingToSave, iteratedRole.getName())
You map your entity classes with identity user and roles in components.xml
<security:jpa-identity-store user-class="your.package.UserAccount" role-class="your.package.Role" />
Check also the Security chapter from Seam documentation which I think is very well written and you can easily perform what you need after going through it.
-
2. Re: user registeration and roles
nitm May 2, 2009 2:21 PM (in response to nitm)thanks for your reply.
adding a boolean to the role entity is a good idea, but i still don't understand how i iterate over the roles..
the IdentityManager has the listRoles method which returns a list of roles but it returns only the names of the roles and not the objects so i can not check if it's the default role.i can query the db (or make an entity-query) for the roles but i thought that maybe there's already a way to do that, plus it sounds like a waste to do that every time a user registers.
thanks, nitzan;