Projet

Général

Profil

0007-attributes_ng-limit-user-roles-depending-on-authenti.patch

Valentin Deniaud, 23 avril 2019 11:29

Télécharger (1,19 ko)

Voir les différences:

Subject: [PATCH 7/7] attributes_ng: limit user roles depending on
 authentication level

 src/authentic2/attributes_ng/sources/django_user.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/authentic2/attributes_ng/sources/django_user.py
83 83
        ctx['django_user_identifier'] = splitted[0]
84 84
    ctx['django_user_full_name'] = user.get_full_name()
85 85
    Role = get_role_model()
86
    roles = Role.objects.for_user(user)
86
    user_auth_level = ctx['request'].session.get('auth_level', 1)
87
    roles = Role.objects.for_user(user).filter(auth_level__lte=user_auth_level)
87 88
    ctx['a2_role_slugs'] = roles.values_list('slug', flat=True)
88 89
    ctx['a2_role_names'] = roles.values_list('name', flat=True)
89 90
    ctx['a2_role_uuids'] = roles.values_list('uuid', flat=True)
90
-