示例#1
0
def productUpdate():
    if request.method == 'GET':
        if ("employee" in request.cookies) & (request.cookies["employee"]
                                              == "True"):
            return render_template("update_productinfo.html")
        else:
            return "FORBIDDEN"
    if request.method == 'POST':
        payload = request.form
        cursor = connection.cursor()
        querystr = '''update product
                        set product_name = :name,
                        product_price = :price,
                        upc_code = :UPC
                        where product_id = :pid    
                '''
        cursor.execute(
            querystr, {
                "pid": payload["inputproductID"],
                "UPC": payload["inputproductCode"],
                "name": payload["inputName"],
                "price": payload["inputPrice"]
            })
        connection.commit()
        redirect_to_main = redirect('/main')
        response = app.make_response(redirect_to_main)
        response.set_cookie('auth_user', value='')  # Add the username arg
        response.set_cookie('employee', value='True')
        return response
示例#2
0
def empSignin():
    if request.method == 'GET':
        return render_template('employee_sign_in.html')
    if request.method == 'POST':
        # SIGN IN LOGIC
        payload = request.form
        userid = None
        cursor = connection.cursor()
        querystr = '''
                    select user_id from account
                    where username = :username
                    and password = :password
                '''
        cursor.execute(
            querystr, {
                "username": payload["inputUsername"],
                "password": payload["inputPassword"]
            })
        for id in cursor:
            userid = id[0]
        redirect_to_main = redirect('/main')
        response = app.make_response(redirect_to_main)
        response.set_cookie('auth_user', value='')  # Add the username arg
        response.set_cookie('employee', value='True')
        return response
示例#3
0
def empSignin():
    if request.method == 'GET':
        return render_template('employee_sign_in.html')
    if request.method == 'POST':
        # SIGN IN LOGIC
        redirect_to_main = redirect('/main')
        response = app.make_response(redirect_to_main)
        response.set_cookie('auth_user', value='')  # Add the username arg
        response.set_cookie('employee', value='True')
        return response
示例#4
0
def signinpage():
    if request.method == 'GET':
        return render_template('customer_sign_in.html')
    if request.method == 'POST':
        # SIGN IN LOGIC
        payload = request.get_json(force=True)
        userid = None
        cursor = connection.cursor()
        querystr = '''
            select user_id from account
            where username = {0}
            and password = {1};
        '''.format(payload["username"], payload["password"])
        cursor.execute(querystr)
        for id in cursor:
            userid = id
        redirect_to_main = redirect('/main')
        response = app.make_response(redirect_to_main)
        if not userid == None:
            response.set_cookie('auth_user',
                                value=userid)  # Add the username arg
        return response
示例#5
0
def logout():
    redirect_to_main = redirect('/main')
    response = app.make_response(redirect_to_main)
    response.set_cookie('auth_user', value='', expires=0)  # Remove cookies
    response.set_cookie('employee', value='', expires=0)  # Remove cookies
    return response
示例#6
0
def test():
    redirect_to_main = redirect('/main')
    response = app.make_response(redirect_to_main)
    response.set_cookie('auth_user', value='test')  # Add the username arg
    return response