Skip to content

Commit

Permalink
Use Group.set() instead of assignment for Django 2.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Roland Pinto committed Jan 2, 2018
1 parent e953ca9 commit c4098e8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion django_saml2_auth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ def _create_new_user(username, email, firstname, lastname):
user = User.objects.create_user(username, email)
user.first_name = firstname
user.last_name = lastname
user.groups = [Group.objects.get(name=x) for x in settings.SAML2_AUTH.get('NEW_USER_PROFILE', {}).get('USER_GROUPS', [])]
groups = [Group.objects.get(name=x) for x in settings.SAML2_AUTH.get('NEW_USER_PROFILE', {}).get('USER_GROUPS', [])]
if parse_version(get_version()) >= parse_version('2.0'):
user.groups.set(groups)
else:
user.groups = groups
user.is_active = settings.SAML2_AUTH.get('NEW_USER_PROFILE', {}).get('ACTIVE_STATUS', True)
user.is_staff = settings.SAML2_AUTH.get('NEW_USER_PROFILE', {}).get('STAFF_STATUS', True)
user.is_superuser = settings.SAML2_AUTH.get('NEW_USER_PROFILE', {}).get('SUPERUSER_STATUS', False)
Expand Down

0 comments on commit c4098e8

Please sign in to comment.