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

Remove issuer from usernames

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