示例#1
0
def login_user(username, session=None):
    user = get_user_by_name(username, session=session)
    if not user:
        user = create_user(username=username,
                           fullname=username,
                           session=session)
    return user
示例#2
0
def get_user_info_by_username(username):
    user = logic.get_user_by_name(username)

    if user is None:
        abort(RESOURCE_NOT_FOUND_STATUS_CODE)

    return user
示例#3
0
def login_user(username: str, email: str, full_name: str, session=None):
    user = get_user_by_name(username, session=session)
    if not user:
        user = create_user(username=username,
                           fullname=full_name,
                           email=email,
                           session=session)
    return user
示例#4
0
    def login_user(self, username, email, fullname, session=None):
        if not username:
            raise AuthenticationError("Username must not be empty!")

        user = get_user_by_name(username, session=session)
        if not user:
            user = create_user(
                username=username, fullname=fullname, email=email, session=session
            )
        return user
示例#5
0
def login_user(username: str, email: str, full_name: str, session=None):
    # Case-insensitive search of the user for backward compatibility.
    # Because it was possible to create e.g. uppercase usernames before.
    user = get_user_by_name(username, case_sensitive=False, session=session)
    if not user:
        # Usernames of new LDAP users are lowered in the DB in order to prevent storing
        # randomly formatted strings from the user input.
        user = create_user(
            username=username.lower(), fullname=full_name, email=email, session=session
        )
    return user
示例#6
0
def authenticate(username, password, session=None):
    """
    Authenticate a PasswordUser with the specified
    username/password.

    :param username: The username
    :param password: The password
    :param session: An active SQLAlchemy session


    :raise AuthenticationError: if an error occurred
    :return: a PasswordUser
    """
    if not username or not password:
        raise AuthenticationError()

    user = get_user_by_name(username, session=session)
    if not user:
        raise AuthenticationError("User does not exist or wrong password")

    if not user.check_password(password):
        raise AuthenticationError("User does not exist or wrong password")

    return AuthUser(user)