Esempio n. 1
0
def sendAmountFormButton():
    username = session['username']

    varpr1 = request.form['jsvar1']
    varTo = request.form['jsvar2']
    print(varpr1)

    s1 = {}
    if varpr1 != '':
        badStrings = [['product', varpr1, False]]
        theRes = areBadStrings(badStrings)

        if theRes != False:
            return json.dumps({
                'username': session['username'],
                'errMessage': theRes
            })

        s2 = getBalance(userNameToId(username), prNameToId(varpr1))
        s2['product'] = varpr1
        s1['balance'] = s2

    s1['userTo'] = varTo
    s1['username'] = username

    return json.dumps(s1)
Esempio n. 2
0
def closeUserButton(args):
    username = session['username']

    s0 = [
        'logic ok', 'user not closed', '', {
            'username': username,
            "okMessage": 'user not closed'
        }
    ]
    return s0
    # skip logic
    pw1 = request.form['jsvar1']

    badStrings = [['password', pw1]]
    theRes = areBadStrings(badStrings)
    if theRes != False:
        return json.dumps({'username': username, 'errMessage': theRes})

    s1 = closeUser(username, pw1)

    if s1[0] == "okay":
        s0 = {'username': username, "okMessage": s1[1]}
    else:
        s0 = {'username': username, "errMessage": s1}
    return json.dumps(s0)
Esempio n. 3
0
def sendAmountButton(args):
    username = session['username']

    userTo = args[0]
    product = args[1]
    amount = args[2]

    badStrings = []
    badStrings.append(['username', userTo])
    badStrings.append(['product', product])
    badStrings.append(['posInt', amount])

    theRes = areBadStrings(badStrings)

    if theRes != False:
        return [
            'logic ok', 'bad arg strings', '', {
                'username': username,
                "errMessage": theRes
            }
        ]

    product_id = prNameToId(product)

    userBal = getBalance(session['user_id'], product_id)
    userAvailableVar1 = int(userBal['available'])

    user2_id = userNameToId(userTo)

    s1 = sendAmount(session['user_id'],
                    user2_id,
                    product_id,
                    amount,
                    userAvailable=userAvailableVar1)

    if s1[0] == 'logic ok':
        if s1[1] == 'amount sent':
            s0 = [
                'logic ok', s1[1],
                json.dumps(args), {
                    'username': username,
                    'okMessage': s1[1]
                }
            ]
            return s0
        s0 = [
            'logic ok', s1[1],
            json.dumps(args), {
                'username': username,
                'errMessage': s1[1]
            }
        ]
        return s0
    return s1
Esempio n. 4
0
def sendAmountButtonNew(args):  # _id
    username = session['username']

    user1_id = args[0]  # From
    user2_id = args[1]  # To
    product_id = args[2]
    amount = args[3]
    sendSort = args[4]

    badStrings = []
    badStrings.append(['posInt', user1_id])
    badStrings.append(['posInt', user2_id])
    badStrings.append(['posInt', product_id])
    badStrings.append(['posInt', amount])

    theRes = areBadStrings(badStrings)

    if theRes != False:
        return [
            'logic ok', 'bad arg strings', '', {
                'username': username,
                "errMessage": theRes
            }
        ]

    userBal = getBalance(user1_id, product_id)
    userAvailableVar1 = int(userBal['available'])

    s1 = sendAmount(user1_id,
                    user2_id,
                    product_id,
                    amount,
                    userAvailable=userAvailableVar1)

    if s1[0] == 'logic ok':
        if s1[1] == 'amount sent':
            s0 = [
                'logic ok', s1[1],
                json.dumps(args), {
                    'username': username,
                    'okMessage': s1[1]
                }
            ]
            return s0
        s0 = [
            'logic ok', s1[1],
            json.dumps(args), {
                'username': username,
                'errMessage': s1[1]
            }
        ]
        return s0
    return s1
Esempio n. 5
0
def addUserButton(args):
    "add new user"

    badStrings = [['username', args[0], False]]
    badStrings.append(['password', args[1]])
    badStrings.append(['password', args[2]])

    theRes = areBadStrings(badStrings)

    if theRes != False:
        return [
            'logic ok', 'bad arg strings', '', {
                'username': '******',
                "errMessage": theRes
            }
        ]

    s1 = addUser(args[0], args[1], args[2])

    if s1[0] == 'logic ok':
        if s1[1] == 'user added':

            requestList = []
            requestType = 'addProduct'
            argsR = [args[0] + '.euro', 'one euro', args[0]]
            requestList.append(['unknown', requestType, argsR])
            argsR = [args[0] + '.mbtc', 'one mbtc', args[0]]
            requestList.append(['unknown', requestType, argsR])

            s0 = [
                'logic ok', s1[1],
                json.dumps([args[0]]), {
                    "newMessage": s1[1],
                    'requestList': requestList
                }
            ]
            return s0

        s0 = [
            'logic ok', s1[1],
            json.dumps([args[0]]), {
                "newMessage": s1[1],
                'requestList': None
            }
        ]
        return s0

    return s1
Esempio n. 6
0
def productPageButton():
    varpr1 = request.form['jsvar1']

    badStrings = [['product', varpr1, False]]
    theRes = areBadStrings(badStrings)

    if theRes != False:
        return json.dumps({
            'username': session['username'],
            'errMessage': theRes
        })

    s1 = productInfo(varpr1)

    s1['username'] = session['username']

    s0j = json.dumps(s1)
    return s0j
Esempio n. 7
0
def userInfoButton():
    "This returns current user information"

    varuser = request.form['jsvar1']

    badStrings = [['username', varuser, False]]
    theRes = areBadStrings(badStrings)

    if theRes != False:
        return json.dumps({'username': username, 'errMessage': theRes})

    s1 = userInfo(varuser)
    # top_one pastepoint 1
    s1['location'] = getLocation(varuser)

    s1['username'] = session['username']

    s0j = json.dumps(s1)
    return s0j
Esempio n. 8
0
def sendRecLogButton():
    username = session['username']

    startfrom = request.form['jsvar1']
    results = request.form['jsvar2']
    user2 = request.form['jsvar3']
    prList = request.form['jsvar4']

    badStrings = []
    if user2 != '':
        badStrings.append(['username', user2, False])

    if startfrom == '':
        startfrom = '0'
    else:
        badStrings.append(['posInt', startfrom])

    if results == '':
        results = '10'
    else:
        badStrings.append(['posInt', results])

    productList = []
    if prList != '':
        productList = prList.split('-')
        for x in productList:
            badStrings.append(['product', x])

    theRes = areBadStrings(badStrings)

    if theRes != False:
        return json.dumps({
            'username': session['username'],
            'errMessage': theRes
        })

    s1 = getSendRecLog(startfrom, results, username, user2, productList)
    #	s1 = getSendRecLog( '', '', '', '', ''  )
    s1['username'] = username

    return json.dumps(s1)
Esempio n. 9
0
def signin():
    username = request.form['username'].lower()
    secretpw = request.form['secret']

    badStrings = [['username', username, False]]
    badStrings.append(['password', secretpw])

    theRes = areBadStrings(badStrings)
    if theRes != False:
        return 'bad pass : '******'logged_in'] = True
        session['username'] = username
        session['user_id'] = varCheckPw[1]
        thestyle = 'style-dark.css'
        session['cssStyle'] = url_for('static', filename=thestyle)
        print('add to signinLog...' + username)
        return "loggedin"
    return 'bad pass'
Esempio n. 10
0
def changePassButton(args):
    "change users password"
    username = session['username']

    badStrings = [['password', args[0]]]
    badStrings.append(['password', args[1]])
    badStrings.append(['password', args[2]])

    theRes = areBadStrings(badStrings)

    if theRes != False:
        return [
            'logic ok', 'bad arg strings', '', {
                'username': username,
                "errMessage": theRes
            }
        ]

    s1 = changePassword(username, args[0], args[1], args[2])

    if s1[0] == "logic ok":
        if s1[1] == "password changed":
            s0 = [
                'logic ok', s1[1], '', {
                    'username': username,
                    "okMessage": s1[1]
                }
            ]
            return s0
        s0 = [
            'logic ok', s1[1], '', {
                'username': username,
                "errMessage": s1[1]
            }
        ]
        return s0

    return s1