Exemple #1
0
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)
Exemple #2
0
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)
Exemple #3
0
def page_not_found(error):
    user = SessionManager.get_user()
    return render_template('page_not_found.html', user=user), 404
Exemple #4
0
def about():
    user = SessionManager.get_user()
    return render_template('about.html', user=user)
Exemple #5
0
 def wrapper(*args, **kwargs):
     user = SessionManager.get_user()
     if not user:
         return redirect(url_for('login'))
     return func(user, *args, **kwargs)