Exemplo n.º 1
0
def createInvoice_route():
    print("request @createInvoice arrived...")
    content = request.get_json()
    response = {}
    if (vc.validateRequest(content) and ua.userIsAuthorized(content, 'createInvoice')):
        response = Main.createInvoice(content)
    if ('error' in content):
        response['error'] = content['error']
        return json.dumps(response, default=str)
    return json.dumps(response, default=str)
Exemplo n.º 2
0
def getQuote_route():
    print("request @getQuote arrived...")
    content = request.get_json()
    response = {}
    if (vc.validateRequest(content) and ua.userIsAuthorized(content, 'getQuote')):
        response = Main.getQuote(content)
    if ('error' in content):
        response['error'] = content['error']
        return json.dumps(response)
    return json.dumps(response)
Exemplo n.º 3
0
def processOrder_route():
    print("request @processOrder arrived...")
    content = request.get_json()
    response = {}
    if (vc.validateRequest(content) and ua.userIsAuthorized(content, 'processOrder')):
        response = Main.processOrder(content)
    if ('error' in content):
        response['error'] = content['error']
        return json.dumps(response, default=str)
    return json.dumps(response, default=str)
Exemplo n.º 4
0
def getAllTransactionHistory_route():
    print("request @getAllTransactionHistory arrived...")
    content = request.get_json()
    response = {}
    if (vc.validateRequest(content) and ua.userIsAuthorized(content, 'getAllTransactionHistory')):
        response = Main.getAllTransactionHistory(content)
    if ('error' in content):
        response['error'] = content['error']
        return json.dumps(response, default=str)
    return json.dumps(response, default=str)
Exemplo n.º 5
0
def login(user):
    response = {}
    if ('username' not in user or 'password' not in user):
        print('field missing')
        response['error'] = 'field missing'
        return response

    isValid = UA.userIsValid(user)
    if (isValid):
        print(user['type'])
        key = UA.generateUserKey()
        user['key'] = key
        response['key'] = key
        response['type'] = user['type']
        response['id'] = user['id']
        tracker = Tracker.getInstance()
        tracker.addUser(user)
        print(user['username'] + " successfully logged in")
    else:
        print("user/pass did not match")
        response['error'] = "user/pass did not match"
    return response
Exemplo n.º 6
0
def emailAvailable(email):
    user = UA.getUserInfo({'username': email})
    if(user):
        return False
    else:
        return True