Esempio n. 1
0
    def get_or_create_user(self, provider, access, info):

        "Create InOut user profile."
        kwargs = {'school': info.pop('school')['name']}
        info.pop('id')
        info.pop('created_at')
        info.pop('updated_at')
        email = info.pop('email')
        kwargs.update(info)
        new = InoutUser(**kwargs)

        digest = hashlib.sha1(smart_bytes(access)).digest()
        # Base 64 encode to get below 30 characters
        # Removed padding characters
        username = force_text(base64.urlsafe_b64encode(digest)).replace(
            '=', '')
        User = get_user_model()
        kwargs = {
            User.USERNAME_FIELD: username,
            'password': None,
            'email': email
        }
        new_user = User.objects.create_user(**kwargs)
        new.participant = new_user
        new.save()
        return new_user
Esempio n. 2
0
    def get_or_create_user(self, provider, access, info):

        "Create InOut user profile."
        kwargs = {
            'school':info.pop('school')['name']
        }
        info.pop('id')
        info.pop('created_at')
        info.pop('updated_at')
        email=info.pop('email')
        kwargs.update(info)
        new=InoutUser(**kwargs)


        digest = hashlib.sha1(smart_bytes(access)).digest()
        # Base 64 encode to get below 30 characters
        # Removed padding characters
        username = force_text(base64.urlsafe_b64encode(digest)).replace('=', '')
        User = get_user_model()
        kwargs = {
            User.USERNAME_FIELD: username,
            'password': None,
            'email':email


        }
        new_user=User.objects.create_user(**kwargs)
        new.participant = new_user
        new.save()
        return new_user
Esempio n. 3
0
 def transform_user_metadata(user_metadata, info, username, email):
     from allaccess.compat import get_user_model
     User = get_user_model()
     user_metadata.update({
         User.USERNAME_FIELD: email,
     })
     return user_metadata
Esempio n. 4
0
 def get_or_create_user(self, provider, access, info):
     "Create a shell custom.MyUser."
     username = info.get('username', None)
     email = info.get('email', None)
     name = info.get('name', None)
     if email is None:
         # No email was given by the provider so create a fake one
         digest = hashlib.sha1(smart_bytes(access)).digest()
         # Base 64 encode to get below 30 characters
         # Removed padding characters
         email = '*****@*****.**' % force_text(
             base64.urlsafe_b64encode(digest)).replace('=', '')
     User = get_user_model()
     """
     kwargs = {
         'email': email,
         'full_name': name,
         'password': None
     }
     """
     u = User.objects.create_user(username, email, None)
     profile = u.get_profile()
     profile.email = email
     profile.full_name = name
     profile.save()
     return u
Esempio n. 5
0
 def get_or_create_user(self, provider, access, info):
     "Create a shell custom.MyUser."
     username = info.get('username', None)
     email = info.get('email', None)
     name = info.get('name', None)
     if email is None:
         # No email was given by the provider so create a fake one
         digest = hashlib.sha1(smart_bytes(access)).digest()
         # Base 64 encode to get below 30 characters
         # Removed padding characters
         email = '*****@*****.**' % force_text(base64.urlsafe_b64encode(digest)).replace('=', '')
     User = get_user_model()
     """
     kwargs = {
         'email': email,
         'full_name': name,
         'password': None
     }
     """
     u = User.objects.create_user(username, email, None)
     profile = u.get_profile()
     profile.email = email
     profile.full_name = name
     profile.save()
     return u
Esempio n. 6
0
 def create_user(self, **kwargs):
     "Create a test User"
     User = get_user_model()
     defaults = {
         User.USERNAME_FIELD: self.get_random_string(),
         'password': self.get_random_string(),
         'email': self.get_random_email()
     }
     defaults.update(kwargs)
     return User.objects.create_user(**defaults)
Esempio n. 7
0
 def create_user(self, **kwargs):
     "Create a test User"
     User = get_user_model()
     defaults = {
         User.USERNAME_FIELD: self.get_random_string(),
         'password': self.get_random_string(),
         'email': self.get_random_email()
     }
     defaults.update(kwargs)
     return User.objects.create_user(**defaults)
Esempio n. 8
0
 def get_or_create_user(self, provider, access, info):
     "Create a shell custom.MyUser."
     email = info.get('email', None)
     if email is None:
         # No email was given by the provider so create a fake one
         digest = hashlib.sha1(smart_bytes(access)).digest()
         # Base 64 encode to get below 30 characters
         # Removed padding characters
         email = '*****@*****.**' % force_text(
             base64.urlsafe_b64encode(digest)).replace('=', '')
     User = get_user_model()
     kwargs = {'email': email, 'password': None}
     return User.objects.create_user(**kwargs)
Esempio n. 9
0
 def get_or_create_user(self, provider, access, info):
     "Create a shell custom.MyUser."
     email = info.get('email', None)
     if email is None:
         # No email was given by the provider so create a fake one
         digest = hashlib.sha1(smart_bytes(access)).digest()
         # Base 64 encode to get below 30 characters
         # Removed padding characters
         email = '*****@*****.**' % force_text(base64.urlsafe_b64encode(digest)).replace('=', '')
     User = get_user_model()
     kwargs = {
         'email': email,
         'password': None
     }
     return User.objects.create_user(**kwargs)
Esempio n. 10
0
    def get_or_create_user(self, provider, access, info):

        username = info.get('username')
        if username is None:
            username = self.generate_username(access)
        else:
            max_length = User._meta.get_field('username').max_length
            username = username[0:max_length]

        if User.objects.filter(username=username).count() > 0:
            username = self.generate_username(access)

        email = info.get('email')

        user = get_user_model()
        kwargs = {
            user.USERNAME_FIELD: username,
            'email': email,
            'password': None
        }
        return User.objects.create_user(**kwargs)