Exemplo n.º 1
0
def register_unconfirmed(username,
                         password,
                         fullname,
                         campaign=None,
                         accepted_terms_of_service=None):
    from osf.models import OSFUser
    user = get_user(email=username)
    if not user:
        user = OSFUser.create_unconfirmed(
            username=username,
            password=password,
            fullname=fullname,
            campaign=campaign,
            accepted_terms_of_service=accepted_terms_of_service)
        user.save()
        signals.unconfirmed_user_created.send(user)

    elif not user.is_registered:  # User is in db but not registered
        user.add_unconfirmed_email(username)
        user.set_password(password)
        user.fullname = fullname
        user.update_guessed_names()
        user.save()
    else:
        raise DuplicateEmailError(
            'OSFUser {0!r} already exists'.format(username))
    return user
Exemplo n.º 2
0
def register_unconfirmed(username, password, fullname):
    user = get_user(username=username)
    if not user:
        user = User.create_unconfirmed(username=username,
                                       password=password,
                                       fullname=fullname)
        user.save()
    elif not user.is_registered:  # User is in db but not registered
        user.add_email_verification(username)
        user.set_password(password)
        user.fullname = fullname
        user.update_guessed_names()
        user.save()
    else:
        raise DuplicateEmailError('User {0!r} already exists'.format(username))
    return user