def user(): if request.method == 'GET': return UserHandler().getAllUser() elif request.method == 'POST': return UserHandler().insertUser(request.get_json()) elif request.method == 'DELETE': return UserHandler().deleteUser(request.get_json())
def showAllSuppliers(): if request.method == 'POST': return UserHandler().registerSupplier(request.form) elif not request.args: return UserHandler().showAllSuppliers() else: return jsonify(Error="Method not allowed."), 405
def getAllUsers(): if request.method == 'POST': print("Request: ", request.json) return UserHandler().insertUserJson(request.json) else: if not request.args: return UserHandler().getAllUsers()
def registerCreditCard(): if request.method == 'POST': return UserHandler().registerCreditCard(request.form) elif request.method == 'PUT': return UserHandler().updateCreditCard(request.form) else: return jsonify(Error="Method not allowed."), 405
def getAllUsers(): if request.method == 'POST': #insert a user return jsonify(Message="User created."), 201 else: if not request.args: return UserHandler().getAllUsers() else: return UserHandler().searchUsers(request.args)
def verify(): global id id = UserHandler().login(request.form['email'], request.form['password']) if not id: return login() else: return dashboard()
def loginREST(user, password): global id id = UserHandler().login(user, password) if not id: return login() else: return dashboard()
def getUserById(user_id): if request.method == 'GET': return UserHandler().getUserById(user_id) elif request.method == 'PUT': #UserHandler().updateUser(user_id,request.form) return jsonify(Message="User update successful"), 200 elif request.method == 'DELETE': #UserHandler().deleteUser(user_id) return jsonify(Message="User delete successful"), 200 else: return jsonify(Error="Method not allowed."), 405
def login(): if request.method == 'POST': # Check for Loggin Attempt #session.pop('user', None) #session.pop('id', None) result = UserHandler().login(request.json) if not (result is None): # PassWord Check, insert query here global loggedUID loggedUID = result[1] return jsonify("Logged In") else: return jsonify(Error="Bad login credentials"), 400
def register(name, username, email, password, phone): return UserHandler().registerUser(name, username, email, password, phone)
def TopUsers(): return UserHandler().getTopPerDay()
def getUserByUsername(username): return UserHandler().searchUsers(username)
def getContacts(): global loggedUID return UserHandler().getAllContactsByID(loggedUID)
def getUserByID(uid): print(request) if request.method == 'GET': return UserHandler().getUserByID(uid)
def usersActive(): return UserHandler().activeUsers()
def getUserById(userId): return UserHandler().getUserById(userId)
def getDislikedMsgByUserId(user_id): return UserHandler().getDislikedMsgByUserId(user_id)
def getPhoneByUserId(user_id): handler = UserHandler() return handler.getPhoneByUserId(user_id)
def getPasswordByUserId(user_id): handler = UserHandler() return handler.getPasswordByUserId(user_id)
def getEmailByUserId(user_id): handler = UserHandler() return handler.getEmailByUserId(user_id)
def getLNameByUserId(user_id): handler = UserHandler() return handler.getLNameByUserId(user_id)
def getUserById(user_id): # if request.method == 'GET': return UserHandler().getUserById(user_id)
def getLoggedUser(): global loggedUID if loggedUID != 0: return UserHandler().getUserByID(loggedUID) else: return jsonify(Error="User is not logged in."), 404
def login(): if request.method == 'POST': return UserHandler().getUserByUsernameAndPassword(request.get_json())
def newContact(): print(request) global loggedUID if request.method == 'POST': return UserHandler().newContact(request.json, loggedUID)
def getUserByUserName(username): return UserHandler().getUserByUserName(username)
def getAllUsersInneed(): if request.method == 'GET': return UserHandler().getAllUsersInneed()
def getAllContactsByID(uid): return UserHandler().getAllContactsByID(uid)
def register(): if request.method == 'POST': return UserHandler().insertUser(request.get_json())
def registerREST(): UserHandler().registerUser(request.form['name'], request.form['email'], request.form['username'], request.form['password'], request.form['phone']) return login()