nopaque/app/main/views.py

33 lines
1.1 KiB
Python
Raw Normal View History

2020-02-17 13:23:19 +00:00
from app.auth.forms import LoginForm
from app.models import User
from flask import flash, redirect, render_template, request, url_for
from flask_login import login_required, login_user
from . import main
2020-02-17 13:23:19 +00:00
@main.route('/', methods=['GET', 'POST'])
2019-08-02 11:24:52 +00:00
def index():
2020-02-17 13:23:19 +00:00
login_form = LoginForm(prefix='login-form')
if login_form.validate_on_submit():
2020-02-19 13:49:52 +00:00
user = User.query.filter_by(username=login_form.user.data).first()
2020-02-17 13:23:19 +00:00
if user is not None and user.verify_password(login_form.password.data):
login_user(user, login_form.remember_me.data)
next = request.args.get('next')
if next is None or not next.startswith('/'):
next = url_for('main.dashboard')
return redirect(next)
flash('Invalid username or password.')
return render_template('main/index.html.j2', login_form=login_form,
title='nopaque')
2019-08-02 11:24:52 +00:00
@main.route('/dashboard')
2019-08-01 08:33:05 +00:00
@login_required
def dashboard():
return render_template('main/dashboard.html.j2', title='Dashboard')
2020-02-10 12:25:15 +00:00
@main.route('/poster')
def poster():
return render_template('main/poster.html.j2', title='Dienste und Prozesse')