Initialise and configure the login manager.

def _init_login_manager(app_):
    """Initialise and configure the login manager."""
    login_manager = flogin.LoginManager()
    login_manager.setup_app(app_)
    login_manager.anonymous_user = Anonymous
    login_manager.login_view = "login"

    users = {app_.config['USERNAME']: User('Admin', 0)}
    names = dict((int(v.get_id()), k) for k, v in users.items())

    @login_manager.user_loader
    def load_user(userid):
        userid = int(userid)
        name = names.get(userid)
        return users.get(name)

    return users, names