bolt / users

Bolt users extension.
MIT License
8 stars 7 forks source link

Improve user's active role identification #23

Closed vlad-ghita closed 2 years ago

vlad-ghita commented 2 years ago

Currently, user's active role is identified as first value in roles list ...

Given this configuration:

# bolt-usersextension.yaml
groups:
    ROLE_MEMBER:
        ...
# security.yaml
security:
    role_hierarchy:
        ROLE_SUPER_MEMBER: ROLE_MEMBER
        ROLE_MEMBER: {}
        ROLE_FOO: {}

Given these users: User1 roles: ROLE_SUPER_MEMBER User2 roles: ROLE_FOO, ROLE_MEMBER

With current implementation, these users are denied access to /profile & profile/edit (at best) or even worse, code outright fails b/c no relevant contenttype was found.

This PR finds active user role by taking group roles and searching them through user's roles, returning first match.