def change_password(): token = request.form["token"] old_password = request.form["old_password"] new_password = request.form["new_password"] # Check if online if database_helper.is_user_online(token) != True: return jsonify(success = False, message = "You are not logged in") # get email from token email = database_helper.get_email_from_token(token) if email is None: return jsonify(success = False, message = "Can't find email matching token") # get and compare current password password = database_helper.get_password(email[0]) if password is None: return jsonify(success = False, message = "Can't find password matching email") if password[0] != old_password: return jsonify(success = False, message = "Wrong password entered") # set new password database_helper.set_password(email[0], new_password) return jsonify(success = True, message = "Password successfully updated")
def change_password(): token = request.form["token"] old_password = request.form["old_password"] new_password = request.form["new_password"] # Check if online if database_helper.is_user_online(token) != True: return jsonify(success=False, message="You are not logged in") # get email from token email = database_helper.get_email_from_token(token) if email is None: return jsonify(success=False, message="Can't find email matching token") # get and compare current password password = database_helper.get_password(email[0]) if password is None: return jsonify(success=False, message="Can't find password matching email") if password[0] != old_password: return jsonify(success=False, message="Wrong password entered") # set new password database_helper.set_password(email[0], new_password) return jsonify(success=True, message="Password successfully updated")
def get_user_messages_by_email(): token = request.form['token'] # token of the user retrieving the data email = request.form["email"] # Check if online if database_helper.is_user_online(token) != True: return jsonify(success = False, message = "You are not logged in") messages = database_helper.get_user_messages(email) return jsonify(success = True, message = "User messages successfully returned", data = messages)
def get_user_messages_by_email(): token = request.form['token'] # token of the user retrieving the data email = request.form["email"] # Check if online if database_helper.is_user_online(token) != True: return jsonify(success=False, message="You are not logged in") messages = database_helper.get_user_messages(email) return jsonify(success=True, message="User messages successfully returned", data=messages)
def sign_out(): token = request.form["token"] #print("LOG OUT") # Check if online if database_helper.is_user_online(token) != True: return jsonify(success = False, message = "You are not logged in") if database_helper.logout_user(token) is None: return jsonify(success = True, message = "User successfully logged out") else: return jsonify(success = False, message = "User not logged in")
def sign_out(): token = request.form["token"] #print("LOG OUT") # Check if online if database_helper.is_user_online(token) != True: return jsonify(success=False, message="You are not logged in") if database_helper.logout_user(token) is None: return jsonify(success=True, message="User successfully logged out") else: return jsonify(success=False, message="User not logged in")
def post_message(): token = request.form['token'] # from message = request.form['message'] email = request.form['email'] # to # Check if online if database_helper.is_user_online(token) != True: return jsonify(success = False, message = "You are not logged in") sender = database_helper.get_email_from_token(token) database_helper.add_message(sender[0], email, message) return jsonify(success = True, message = "Message successfully posted")
def post_message(): token = request.form['token'] # from message = request.form['message'] email = request.form['email'] # to # Check if online if database_helper.is_user_online(token) != True: return jsonify(success=False, message="You are not logged in") sender = database_helper.get_email_from_token(token) database_helper.add_message(sender[0], email, message) return jsonify(success=True, message="Message successfully posted")
def get_user_data_by_email(): token = request.form['token'] # token of the user retrieving the data email = request.form['email'] # Check if online if database_helper.is_user_online(token) != True: return jsonify(success = False, message = "You are not logged in") user = database_helper.get_user(email) if user is None: return jsonify(success = False, message = "Can't find user data") u = {} u['email'] = user[0] u['firstname'] = user[1] u['familyname'] = user[2] u['country'] = user[3] u['city'] = user[4] u['gender'] = user[5] return jsonify(success = True, message = "User data successfully returned", data = u)
def get_user_data_by_email(): token = request.form['token'] # token of the user retrieving the data email = request.form['email'] # Check if online if database_helper.is_user_online(token) != True: return jsonify(success=False, message="You are not logged in") user = database_helper.get_user(email) if user is None: return jsonify(success=False, message="Can't find user data") u = {} u['email'] = user[0] u['firstname'] = user[1] u['familyname'] = user[2] u['country'] = user[3] u['city'] = user[4] u['gender'] = user[5] return jsonify(success=True, message="User data successfully returned", data=u)