Beispiel #1
0
def index():
    """ Index Page.
    """
    # check for existing session in browser cookies
    try:
        ema.ema_logout(session['emaSession']['session_id'])
        session.clear()
        logout_user()
    except:
        pass
    logger.debug('FUNC::::::: app.main.route.index')
    form = LoginForm()
    
    if form.validate_on_submit():
        logger.debug ('Performing logon')
        session['username'] = request.form['username']
        session['password'] = request.form['password']
        
        user = User.query.filter_by(username = request.form['username']).first()
        if user is not None and user.verify_password(request.form['password']):
            login_user(user)
            session['emaSession'] = ema.emaLogin()
            return redirect(url_for(('main.subscribers')))
        flash('Invalid Username and Password')
    
    logger.debug('** Leaving FUNC::::::: app.main.route.index')
    return render_template('/login.html', form = form)   # I believe that this is the first function/view called
Beispiel #2
0
def logout():
    logger.debug('FUNC:::::: app.route.logout')
    ema.ema_logout(session['emaSession']['session_id'])
    session.clear()
    logout_user()
    logger.debug('** Leaving FUNC:::::: app.route.logout')
    flash ('Logged Out')
    return redirect(url_for(('main.index')))