Skip to content
Snippets Groups Projects
Commit 3c6c9b2b authored by MaximeOLIVA's avatar MaximeOLIVA
Browse files

change password v1

parent 99dde746
No related branches found
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -111,3 +111,13 @@ def get_data_email(email): ...@@ -111,3 +111,13 @@ def get_data_email(email):
return None return None
except: except:
return None return None
def change_password(email, newpassword):
try:
sql = "UPDATE USERS SET password = 'newpassword1' WHERE email = 'cbdgsdsd11mail.com';"
get_db().execute(sql)
get_db().commit()
return True
except:
return False
...@@ -82,8 +82,13 @@ def sign_out(): ...@@ -82,8 +82,13 @@ def sign_out():
def change_password(): def change_password():
data = request.get_json() data = request.get_json()
if('token' in data and 'oldPassword' in data and 'newPassword' in data): if('token' in data and 'oldPassword' in data and 'newPassword' in data):
return True if database_helper.is_online(data['token']):
#return "", 204 email = database_helper.tokenToEmail(data['token'])
#check old password is good
if database_helper.change_password(email, data['newPassword']):
return "", 204
else:
return "", 401
else: else:
return "", 400 return "", 400
...@@ -94,7 +99,7 @@ def get_user_data_token(token): ...@@ -94,7 +99,7 @@ def get_user_data_token(token):
if email: if email:
return get_user_data_email(token, email) return get_user_data_email(token, email)
else: else:
return "", 403 return "", 401
@app.route("/account/get/data/<token>/<email>", methods = ['GET']) @app.route("/account/get/data/<token>/<email>", methods = ['GET'])
...@@ -108,14 +113,13 @@ def get_user_data_email(token, email): ...@@ -108,14 +113,13 @@ def get_user_data_email(token, email):
"gender": data[2], "gender": data[2],
"city": data[3], "city": data[3],
"country": data[4], "country": data[4],
"email": data[5], "email": data[5]
"password": data[6],
} }
return jsonify(value), 200 return jsonify(value), 200
else: else:
return "", 404 return "", 404
else: else:
return "", 403 return "", 401
def generate_token(): def generate_token():
characters = string.ascii_letters + string.digits characters = string.ascii_letters + string.digits
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment