Beispiel #1
0
def login():
    #如果已经LOGIN,重定向到首页
    if current_user.is_authenticated:
        return redirect('/')
    form = LoginForm()

    if form.validate_on_submit():
        # flash('username="******", password='******'/')

        else:
            flash('username or password is wrong')
            return redirect('auth/login')

    else:
        template_name = 'login.html'
        return render_template(template_name, title='Sign In', form=form)
Beispiel #2
0
def login():
    if current_user.is_authenticated:
        return redirect('/')

    form = LoginForm()
    if form.validate_on_submit():
        username = form.username.data
        password = form.password.data
        user_controller = UserController()
        user = user_controller.query(username=username, password=password)
        print(user)

        if user:
            login_user(user)
            return redirect('/')
        else:
            flash('username or password is worry')
            return redirect('/auth/login')
    else:
        template_naeme = 'login.html'
        return render_template(template_naeme, title='Sign In', form=form)