()
return render_template('user/login.html', data=data, form=form)
User login page: This is a basic login page
User login page: This is a basic login page
User login page : This is a basic login page
def login_page():
    ''' User login page: This is a basic login page'''
    data = {
        'active': 'login',
        'loggedin': False
    }

    # Define and Validate the form
    form = LoginForm(request.form)
    if request.method == "POST":
        if form.validate():
            email = form.email.data
            password = form.password.data

            # Start user definition
            user = User()
            user.config = app.config
            if user.get('username', email, g.rdb_conn):
                result = user.checkPass(password, g.rdb_conn)
                if result is True:
                    data['loggedin'] = True
                    print("/login - User login successful")
                    flash('You are logged in.', 'success')
                    # Start building response
                    resp = make_response(
                        redirect(url_for('member.dashboard_page')))
                    cdata = cookies.genCdata(
                        user.uid, app.config['SECRET_KEY'])
                    timeout = int(time.time()) + \
                        int(app.config['COOKIE_TIMEOUT'])
                    # Set cookie as securely as possible
                    resp.set_cookie(
                        'loggedin', cdata, expires=timeout, httponly=True)
                    print("Setting cookie")
                    return resp
                else:
                    print("/login - User login error: wrong password")
                    flash('Password does not seem valid.', 'danger')
            else:
                print("/login - User login error: invalid user")
                flash('Uhh... User not found.', 'danger')
        else:
            print("/login - User login error: invalid form")
            flash('Form is not valid.', 'danger')

    # Return Login Page
    return render_template('user/login.html', data=data, form=form)
def login_page ( ) : data = { 'active' : 'login' , 'loggedin' : False } # Define and Validate the form form = LoginForm ( request . form ) if request . method == "POST" : if form . validate ( ) : email = form . email . data password = form . password . data # Start user definition user = User ( ) user . config = app . config if user . get ( 'username' , email , g . rdb_conn ) : result = user . checkPass ( password , g . rdb_conn ) if result is True : data [ 'loggedin' ] = True print ( "/login - User login successful" ) flash ( 'You are logged in.' , 'success' ) # Start building response resp = make_response ( redirect ( url_for ( 'member.dashboard_page' ) ) ) cdata = cookies . genCdata ( user . uid , app . config [ 'SECRET_KEY' ] ) timeout = int ( time . time ( ) ) + int ( app . config [ 'COOKIE_TIMEOUT' ] ) # Set cookie as securely as possible resp . set_cookie ( 'loggedin' , cdata , expires = timeout , httponly = True ) print ( "Setting cookie" ) return resp else : print ( "/login - User login error: wrong password" ) flash ( 'Password does not seem valid.' , 'danger' ) else : print ( "/login - User login error: invalid user" ) flash ( 'Uhh... User not found.' , 'danger' ) else : print ( "/login - User login error: invalid form" ) flash ( 'Form is not valid.' , 'danger' ) # Return Login Page return render_template ( 'user/login.html' , data = data , form = form )