-
1. Re: how get user roles from database und use it in seam
nickarls Apr 23, 2008 11:55 AM (in response to kevmaster)fetch the user roles from the db and use identity.addRole()
-
2. Re: how get user roles from database und use it in seam
kevmaster Apr 23, 2008 2:03 PM (in response to kevmaster)Thx, but I dont come to a solution.
Do u have an code snippet or an example to solve this easily? -
3. Re: how get user roles from database und use it in seam
stereoscope Apr 23, 2008 2:16 PM (in response to kevmaster)hi !
you got your user if the password is correct!
user = (User) results.get(0);
now you can call the attributes you like from this object by using the getters...
identity.addRole(user.getRole());
cu
-
4. Re: how get user roles from database und use it in seam
nickarls Apr 23, 2008 2:19 PM (in response to kevmaster)something like
List<String> roles = em.createQuery("select r from Roles where r.username=#{identity.username}").getResultList(); for (String role : roles) { identity.addRole(role); }
if you can't get it work from there, you are in a world of trouble anyways ;-)
-
5. Re: how get user roles from database und use it in seam
nickarls Apr 23, 2008 2:20 PM (in response to kevmaster)Aah, you have only one role. Follow FRG:s advice...
-
6. Re: how get user roles from database und use it in seam
kevmaster Apr 23, 2008 2:57 PM (in response to kevmaster)Thx 4 help, it works. i used that:
identity.addRole(user.getUserRole());
but i had to change the user roles, this were enumerations.
-
7. Re: how get user roles from database und use it in seam
danielc.roth Apr 23, 2008 3:53 PM (in response to kevmaster)Or use .name() on the Enum object :-)
-
8. Re: how get user roles from database und use it in seam
kevmaster Apr 23, 2008 5:18 PM (in response to kevmaster)OK thx, i'll try it.
Next goal is to set multiple rules. That means an user can claim more than one user roles.
Theres a class User and a class UserRoles with an enumeration class which consists of 4 roles.
I hope its the right way to establish the role concept.Advices are desired. 8)