def basic_login_from_request(request, app):
    """Check 'Authorization' headers and log the user in if possible.

    :param request: The input request
    :type request: :class:`flask.Request`

    :param app: The application context
    :type app: :class:`burpui.server.BUIServer`
    """
    if app.auth != 'none':
        if request.headers.get('X-From-UI', False):
            return None
        auth = request.authorization
        if auth:
            from flask import session, g
            app.logger.debug('Found Basic user: {}'.format(auth.username))
            refresh = False
            if 'login' in session and session['login'] != auth.username:
                refresh = True
                session.clear()
                session['login'] = auth.username
            session['language'] = request.headers.get('X-Language', 'en')
            user = app.uhandler.user(auth.username, refresh)
            if user.active and user.login(auth.password):
                from flask_login import login_user
                from .sessions import session_manager
                login_user(user)
                if request.headers.get('X-Reuse-Session', False):
                    session_manager.store_session(auth.username, request.
                        remote_addr, request.headers.get('User-Agent'),
                        remember=False, api=True)
                else:
                    g.basic_session = True
                app.logger.debug('Successfully logged in')
                return user
            app.logger.warning('Failed to log-in')
    return None
