Grails Spring Security check if User belongs to Group (RoleGroup)

0

I have the following domain classes:

User hasOne RoleGroup hasMany Role

  • Examples:

RoleGroup : Admin, Professional, Customer, ...

Role : ROLE_ACTION_1, ROLE_ACTION_2, ...

How do I check if the User belongs to a specific RoleGroup?

In @Secured I can only insert "ROLE" ... Do I need to include all the ROLEs in the group whenever I want to grant access to a specific group? Is there a viable way to do this?

    
asked by anonymous 28.07.2016 / 21:23

1 answer

0

Generally when you use the plugin command to generate the classes are generated User, Profile, UserProfile classes.

    grails s2-quickstart com.yourapp Usuario Perfil

In this third there is a static method called: get (long userId, long profileId), your call would be like this.

    UsuarioPerfil.get(usuario.id, perfil.id)

If it exists, it returns a UserProfile object that is relation between the two, User + Profile.

    
08.02.2017 / 12:04