Ejemplo n.º 1
0
def login():
    # If they're already logged in, forward them to their destination.
    if check_login_cookie():
        print 'Redirecting for already auth'
        return redirect(request.values.get('next') if 'next' in request.values else url_for('index'), code=302)
    
    if request.method == 'POST':
        # Otherwise, we need to get the password from the form, validate it, and
        if 'pw' in request.values:
            if place_login_cookie(request.values['pw']):
                print 'Login successful!'
                return redirect(request.values.get('next') if 'next' in request.values else url_for('index'), code=302)
            else:
                flash('Incorrect password.')
        else:
            flash('Incomplete request.')
    return render_template('login.html')
Ejemplo n.º 2
0
 def _handle_view(self, name, **kwargs):
     if not check_login_cookie():
         return redirect(url_for('login.login', next=request.url), code=302)