def authenticate(self, profile): # django.contrib.auth.models.User.username is required and # has a max_length of 30 so to ensure that we don't go over # 30 characters we url-safe base64 encode the sha1 of the identifier # returned from janrain and slice `=` from the end. hashed_user = safe_encode(sha1(profile['identifier']).digest())[:-1] try : u = User.objects.get(username=hashed_user) except User.DoesNotExist: fn, ln = self.get_name_from_profile(profile) u = User( username=hashed_user, password='', first_name=fn, last_name=ln, email=self.get_email(profile) ) # Set an unusable password to protect unauthorized access. u.set_unusable_password() u.is_active = True u.is_staff = False u.is_superuser = False u.save() return u
def authenticate(self, profile): # django.contrib.auth.models.User.username is required and # has a max_length of 30 so to ensure that we don't go over # 30 characters we url-safe base64 encode the sha1 of the identifier # returned from janrain and slice `=` from the end. hashed_user = safe_encode(sha1(profile['identifier']).digest())[:-1] try: u = User.objects.get(username=hashed_user) except User.DoesNotExist: fn, ln = self.get_name_from_profile(profile) u = User(username=hashed_user, password='', first_name=fn, last_name=ln, email=self.get_email(profile)) # Set an unusable password to protect unauthorized access. u.set_unusable_password() u.is_active = True u.is_staff = False u.is_superuser = False u.save() return u