Commit e388a43f authored by Sandro Lutz's avatar Sandro Lutz
Browse files

Add login / logout endpoints

parent eeef0bf2
......@@ -47,7 +47,8 @@ section .container {
cursor: pointer;
#creator input {
#creator input,
.login input {
max-width: 400px;
text-align: center;
display: inline-block;
{% extends 'base.html' %}
{% block title %} AMIV Burger Login {% endblock %}
{% block content %}
<header class="masthead bg-primary text-white text-center">
<div class="container login">
<h2 class="text-center text-uppercase text-white">Login required</h2>
<div class="text-center">
<p>You need to log in with your nethz credentials to create or vote on any burger.</p>
<hr class="star-light">
<form method="POST" action="/login">
<input class="form-control" id="input_user" name="user" type="text" placeholder="nethz username"/><br/>
<input class="form-control" id="input_passwd" name="passwd" type="password" placeholder="Password"/><br/>
<input class="btn btn-primary" type="submit" value="sign in"/>
{% endblock %}
\ No newline at end of file
Contains all views
from app import app
from app import app, ldap
from datetime import datetime
from .models import db, Burger
from flask import flash, g, redirect, render_template, request, url_for
from flask import flash, g, redirect, render_template, request, url_for, session
def vote():
# @ldap.login_required
def index():
Front page. Shows a list of all burgers
return render_template('index.html')
def load_user():
Load user data before any request processing
if session['nethz']:
g.user = session['nethz']
except KeyError:
g.user = None
@app.route('/login', methods=['GET', 'POST'])
def login():
Login page. LDAP-Login only.
if g.user:
return redirect(url_for('index'))
if request.method == 'POST':
user = request.form['user']
passwd = request.form['passwd']
test = ldap.bind_user(user, passwd)
if test is None or passwd == '':
flash('Invalid credentials', 'error')
g.user = session['nethz'] = user
return redirect(url_for('index'))
return render_template('login.html')
def logout():
Logout page
session.pop('nethz', None)
g.user = None
flash('Successfully logged out.')
return redirect(url_for('index'))
@app.route('/new', methods=['GET', 'POST'])
# @ldap.login_required
def create():
Burger creator
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment