add new users to default collectivity

This commit is contained in:
Frédéric Péters 2016-12-23 10:37:40 +01:00
parent 777eb2f1d6
commit b1ed899f50
1 changed files with 7 additions and 1 deletions

View File

@ -24,6 +24,8 @@ import lasso
from mellon.adapters import DefaultAdapter
from authentic2.models import Attribute
from authentic2.a2_rbac.utils import get_default_ou
class AuthenticAdapter(DefaultAdapter):
def lookup_user(self, idp, saml_attributes):
@ -35,7 +37,11 @@ class AuthenticAdapter(DefaultAdapter):
saml_attributes['name_id_content_orig'] = saml_attributes['name_id_content']
saml_attributes['name_id_content'] = saml_attributes['urn:be:fedict:iam:attr:fedid'][0]
saml_attributes['name_id_format'] = lasso.SAML2_NAME_IDENTIFIER_FORMAT_UNSPECIFIED
return super(AuthenticAdapter, self).lookup_user(idp, saml_attributes)
user = super(AuthenticAdapter, self).lookup_user(idp, saml_attributes)
if not user.ou_id:
user.ou = get_default_ou()
user.save()
return user
def create_user(self, user_class):
return user_class.objects.create()