예제 #1
0
파일: server.py 프로젝트: simplerr/TDDD97
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")
예제 #2
0
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")
예제 #3
0
파일: server.py 프로젝트: simplerr/TDDD97
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)
예제 #4
0
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)
예제 #5
0
파일: server.py 프로젝트: simplerr/TDDD97
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")
예제 #6
0
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")
예제 #7
0
파일: server.py 프로젝트: simplerr/TDDD97
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")	
예제 #8
0
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")
예제 #9
0
파일: server.py 프로젝트: simplerr/TDDD97
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)
예제 #10
0
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)