def change_password(token, old_password, new_password): user = database_helper.user_signedin(token) if user is None: return json.dumps({"success": False, "message": "You are not logged in."}) if database_helper.get_password(user[0]) != hashlib.sha512(old_password.encode('utf-8')).hexdigest(): return json.dumps({"success": False, "message": "Wrong password."}) database_helper.update_password(user[0], hashlib.sha512(new_password.encode('utf-8')).hexdigest()) return json.dumps({"success": True, "message": "Password changed."})
def change_password(): token = request.form['token'] old_password = request.form['old_password'] new_password = request.form['new_password'] if token in logged_in_users: email = logged_in_users[token] if dh.validate_password(email, old_password): dh.update_password(email, new_password) return json.dumps({"success": True, "message": "Password changed"}) else: return json.dumps({"success": False, "message": "Wrong password"}) return json.dumps({"success": False, "message": "You are not signed in"})
def change_password(): body = json.loads(request.data.decode("utf-8")) token = body['token'] old_password = _password_hasher(body['oldPassword']) new_password = _password_hasher(body['newPassword']) user = database_helper.email_from_token(token) result = database_helper.find_user_with_password(user['email'], old_password) if result != None: database_helper.update_password(user['email'], new_password) return _return_json_message(True, "Successfully changed password") else: return _return_json_message(False, "No such user")
def change_password(): token = request.form['token'] new_password = request.form['new_password'] old_password = request.form['old_password'] if token not in logged_in_users: return jsonify({"success": False, "message": "You must be logged in to change password."}) else: email = logged_in_users[token] is_valid = database_helper.is_valid_login(email, old_password) if not is_valid: return jsonify({"success": False, "message": "Old password is not correct."}) else: database_helper.update_password(email, new_password) return jsonify({"success": True, "message": "Password changed successfully."})
def change_password(): hash = request.form['hash'] oldPass = request.form['old'] newPass = request.form['new'] email = request.form['email'] logged_in_user = database_helper.get_logged_in_user_by_email(email) if logged_in_user: token = logged_in_user[1] params = "&email=" + email + "&old=" + oldPass + "&new=" + newPass + "&hash=" if check_hash(hash, params, token): if validate_password(newPass): if check_password(token, oldPass): user = database_helper.get_user_by_email(email) salt = user[7] result = database_helper.update_password( email, create_hash(newPass, salt)) if result: return_code = create_return_code( True, 'Password changed') else: return_code = create_return_code( False, 'Could not change password') else: return_code = create_return_code(False, 'Wrong password') else: return_code = create_return_code(False, 'Enter a valid password') else: return_code = create_return_code(False, 'Bad token') else: return_code = create_return_code(False, 'You are not logged in') return json.dumps(return_code)
def change_password(): arg = request.args.to_dict() token = arg.get('token', None) oldPassword = arg.get('oldPassword', None) newPassword = arg.get('newPassword', None) if token in logged_users_by_token: email = logged_users_by_token[token] user = database_helper.get_user_data_by_email(email) if user['password'] == oldPassword: database_helper.update_password(email, newPassword) response = {'success': True, 'message': 'Password changed.'} else: response = {'success': False, 'message': 'Wrong password.'} else: response = {'success': False, 'message': 'You are not logged in.'} return json.dumps(response)
def change_password(): token = request.headers.get("Authorization") data = request.get_json() keys = ["old_password", "new_password"] if not check_input_data(data, keys): return jsonify(success=False, message="Wrong input data.") if not database_helper.check_token(token): return jsonify(success=False, message="You must be logged in to change password!") email = database_helper.get_email_by_token(token) if database_helper.check_valid_user(email, data['old_password']): database_helper.update_password(data['new_password'], email) return jsonify(success=True, message="Password changed!") else: return jsonify(success=False, message="Wrong old password!")
def change_password(): hashedData = request.headers.get('hashedData') oldPassword = request.json['oldPassword'] newPassword = request.json['newPassword'] passwordConfirmation = request.json['passwordConfirmation'] email = request.json['email'] data = email + newPassword + oldPassword serverHash = server_hash(data, email) if (serverHash == hashedData): oldPasswordHashed = database_helper.get_hashedpw_by_email(email) if (bcrypt.check_password_hash(oldPasswordHashed, oldPassword)): if (newPassword == passwordConfirmation): if (len(newPassword) > 4): newPasswordHashed = bcrypt.generate_password_hash( newPassword) database_helper.update_password(email, newPasswordHashed) return json.dumps({ 'success': True, 'message': 'Password has been changed' }) else: return json.dumps({ 'success': False, 'message': 'New Password is too short' }) else: return json.dumps({ 'success': False, 'message': 'New Password and Password confirmation are different' }) else: return json.dumps({ 'success': False, 'message': 'Old Password is incorrect' }) else: return json.dumps({ 'success': False, 'message': 'You have to be logged in' })
def Change_password(): data = request.json token = data["token"] oldPassword = data["oldpassword"] newPassword = data["newpassword"] if database_helper.find_inlogged(token) is not None: email = database_helper.find_inlogged(token) if oldPassword == database_helper.find_user(email)["password"]: database_helper.update_password(email, newPassword) return json.dumps({ "success": True, "message": "Password changed." }) else: return json.dumps({"success": False, "message": "Wrong password."}) else: return Json.dumps({ "success": False, "message": "You are not logged in." })
def change_password(): data = request.json token = data['token'] old_password = data['old_password'] new_password = data['new_password'] email = database_helper.get_email_by_token(token) response = {} if email is None: response['success'] = False response['message'] = 'You are not signed in.' else: if database_helper.check_user(email, old_password): salt = str(binascii.hexlify(os.urandom(16))) hnew_password = str(binascii.hexlify(hashlib.pbkdf2_hmac('sha256', str(new_password), salt, 100000))) database_helper.update_password(email, hnew_password, salt) response['success'] = True response['message'] = 'Password changed.' else: response['success'] = False response['message'] = 'Wrong password.' return json.dumps(response)