Beispiel #1
0
def user_loader(name):
    repository = UsersRepository()
    response = repository.list(filters=dict(name=name))

    if not response:
        return None

    user = response[0]
    user.is_active = True
    user.is_authenticated = True
    user.is_anonymous = False
    user.get_id = lambda _: user.name

    return user
Beispiel #2
0
def request_loader(request):
    name = request.form.get('name')

    repository = UsersRepository()
    response = repository.list(filters=dict(name=name))

    if not response:
        return None

    user = response[0]
    user.is_authenticated = repository.check_password(user,
                                                      request.form['password'])
    user.is_active = True
    user.is_anonymous = False
    user.get_id = lambda _: user.name

    return user