Commit 18d6c790 authored by Tross Yvormes's avatar Tross Yvormes

Merge branch 'user_group_rename' into 'master'

handle user/group renames

Closes #1

See merge request !1
parents bc07ba5d fab7b807
......@@ -24,9 +24,11 @@ class TESTOAuth2Backend(ModelBackend):
self.run_verifiers(profile)
if getattr(settings, 'TEST_OAUTH_RESPECT_ID', False):
user, _ = get_user_model().objects.get_or_create(
user, _ = get_user_model().objects.update_or_create(
pk=profile['id'],
username=profile['username']
defaults={
'username': profile['username']
}
)
else:
user, _ = get_user_model().objects.get_or_create(
......@@ -80,8 +82,11 @@ class TESTOAuth2Backend(ModelBackend):
user.groups.clear()
for g in groups:
group, _ = Group.objects.get_or_create(
id=g['id'], name=g['name']
group, _ = Group.objects.update_or_create(
id=g['id'],
defaults={
'name': g['name']
}
)
user.groups.add(group)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment