Exemplo n.º 1
0
def login():
    form = LoginForm()
    if form.validate_on_submit():
        try:
            user = User.get(User.user_username == form.username.data)
            if user.user_password == form.password.data:
                #user.is_authenticated = True
                login_user(user)
                session['username'] = request.form['username']
                flash("You're now logged in!")
                return redirect(url_for('index'))
            else:
                flash("Error on password or username")
        except:
            flash("Error !!,You should start again")
    return render_template('login.html', form=form)
Exemplo n.º 2
0
def load_user(user_id):
    try:
        return User.get(user_id)
    except:
        return "Error account"