Esempio n. 1
0
def load_user(userid):
    user = User.query.get(int(userid))

    if user is not None:
        user = LoginUser(user.id, user.email_address, user.supplier_code, None,
                         user.locked, user.active, user.name, user.role,
                         user.terms_accepted_at, user.application_id,
                         user.frameworks)
    return user
Esempio n. 2
0
def load_user(userid):
    user = User.query.options(noload('*')).get(int(userid))

    if user is not None:
        notification_count = get_notification_count(user)
        teams = get_teams(user)
        user = LoginUser(user.id, user.email_address, user.supplier_code, None,
                         user.locked, user.active, user.name, user.role,
                         user.terms_accepted_at, user.application_id,
                         user.frameworks, notification_count, teams)

    return user
Esempio n. 3
0
def load_user_from_request(request):
    if not current_app.config.get('BASIC_AUTH'):
        return None

    payload = get_token_from_headers(request.headers)

    if payload is None:
        return None

    email_address, password = b64decode(payload).split(':', 1)
    user = User.get_by_email_address(email_address.lower())

    if user is not None:
        if encryption.authenticate_user(password, user):
            user = LoginUser(user.id, user.email_address, user.supplier_code,
                             None, user.locked, user.active, user.name,
                             user.role, user.terms_accepted_at,
                             user.application_id, user.frameworks)
            return user