Commit bf219661 authored by lukas.burgey's avatar lukas.burgey
Browse files

Remove issuer from usernames

parent 3303ccd8
Pipeline #109032 passed with stage
in 1 minute and 23 seconds
...@@ -127,30 +127,20 @@ class User(AbstractUser): ...@@ -127,30 +127,20 @@ class User(AbstractUser):
if 'sub' not in userinfo: if 'sub' not in userinfo:
raise ValueError('Missing attribute in userinfo: sub') raise ValueError('Missing attribute in userinfo: sub')
username = '{}@{}'.format( user, created = cls.objects.get_or_create(
userinfo['sub'],
idp.name.replace(' ', '_'),
)
if cls.objects.filter(
username=username,
idp=idp,
).exists():
return cls.objects.get(
username=username,
idp=idp,
)
user = cls(
user_type=cls.TYPE_CHOICE_USER, user_type=cls.TYPE_CHOICE_USER,
username=username,
sub=userinfo['sub'], sub=userinfo['sub'],
idp=idp, idp=idp,
defaults={
'username': '{}@{}'.format(userinfo['sub'], idp.id),
},
) )
user.save()
user.update_userinfo(userinfo) if created:
LOGGER.info('construct_from_userinfo: new user: %s', user) LOGGER.info('construct_from_userinfo: new user: %s', user)
user.update_userinfo(userinfo)
user.save()
return user return user
@classmethod @classmethod
......
Supports Markdown
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