Beispiel #1
0
async def login():
    if current_user.is_authenticated:
        return quart.redirect(url_for('main'))

    if request.method == "POST":
        data = await request.form
        login = data.get("login")
        user = User.load(login)

        error = await user.login(ip=data.get("ip"),
                                 login=login,
                                 password=data.get("password"))
        if not error:
            error = await user.initialize()

        if error:
            return quart.redirect(url_for('login'))
        login_user(user)
        return quart.redirect(quart.url_for('main'))
    else:
        return await quart.render_template('login.html')
Beispiel #2
0
def load_user(user_id: str):
    return User.load(user_id)