def create_user(strategy, details, user=None, *args, **kwargs): """ Used in the pipeline of social auth for creating user account. See: https://github.com/omab/python-social-auth/blob/master/social/pipeline/user.py#L58 """ result = social_create_user(strategy, details, user=user, *args, **kwargs) if result: if result.get('is_new'): if not result.get('user').email: return return result
def create_user(strategy, details, user=None, *args, **kwargs): """ Substitution method for stock social create_user that catches email validation error and redirects to login """ from student.views import AccountEmailAlreadyExistsValidationError try: return social_create_user(strategy, details, user, *args, **kwargs) except AccountEmailAlreadyExistsValidationError as exc: logger.exception(exc.message) # We're raising an exception that inherits from AuthException. Such exceptions are properly handled # by social auth pipeline: their string representation (see __str__ method) is displayed to user on the page # we're redirecting to. raise EmailAlreadyInUseException(exc.message, details['email'])
def create_user(strategy, details, response, uid, user=None, *args, **kwargs): info = social_create_user(strategy, details, response, uid, user, *args, **kwargs) if info['is_new']: user = info['user'] if settings.PYHN_NEW_USER_CAN_SUBMIT: permission = Permission.objects.get(codename='can_submit') user.user_permissions.add(permission) profile = Profile(user_ptr=user) profile.username = user.username profile.email = user.email profile.about = '' profile.save() return {'is_new': True, 'user': user}
def create_user(strategy, details, response, uid, user=None, *args, **kwargs): info = social_create_user( strategy, details, response, uid, user, *args, **kwargs ) if info['is_new']: user = info['user'] if settings.PYHN_NEW_USER_CAN_SUBMIT: permission = Permission.objects.get(codename='can_submit') user.user_permissions.add(permission) profile = Profile(user_ptr=user) profile.username = user.username profile.email = user.email profile.about = '' profile.save() return {'is_new': True, 'user': user}