def login(): error = None if request.method == 'POST': user = UserManager.login( request.form['login'], request.form['password']) if user: SessionManager.start_session(user) return redirect(url_for('dashboard')) else: error = "Incorrect username or password" else: user = SessionManager.get_user() if user: return redirect(url_for('dashboard')) return render_template('login.html', error=error)
def signup(): error = None if request.method == 'POST': user = UserManager.register( request.form['login'], request.form['display_name'], request.form['password']) if user: SessionManager.start_session(user) return redirect(url_for('dashboard')) else: error = "Login is already used" else: user = SessionManager.get_user() if user: return redirect(url_for('dashboard')) return render_template('signup.html', error=error)
def page_not_found(error): user = SessionManager.get_user() return render_template('page_not_found.html', user=user), 404
def about(): user = SessionManager.get_user() return render_template('about.html', user=user)
def wrapper(*args, **kwargs): user = SessionManager.get_user() if not user: return redirect(url_for('login')) return func(user, *args, **kwargs)