<commit_before>const service = require('feathers-mongoose');
const passwordRecovery = require('./model');
const hooks = require('./hooks');
const AccountModel = require('./../account/model');

class ChangePasswordService {
	constructor() {
	}

	create(data) {
		return AccountModel.update({ _id: data.accountId }, { password: data.password })
			.then(account => passwordRecovery.update({ _id: data.resetId }, { changed: true })
				.then((_ => account))).catch(error => error);
	}
}

module.exports = function () {
	const app = this;

	const options = {<commit_msg>Fix security issue with password recovery. Now a not used recovery token need to be used for password reset ... before account id was enough.<commit_after>const service = require('feathers-mongoose');
const passwordRecovery = require('./model');
const hooks = require('./hooks');
const AccountModel = require('./../account/model');

class ChangePasswordService {
	create(data) {
		return passwordRecovery.findOne({ _id: data.resetId, changed: false })
			.then((pwrecover) => AccountModel.update({ _id: pwrecover.account }, { password: <PASSWORD> })
				.then((account) => passwordRecovery.update({ _id: data.resetId }, { changed: true })
					.then((_ => account)))).catch((error) => error);
	}
}

module.exports = function () {
	const app = this;

	const options = {
{'fraction_non_alphanumeric': 0.1634182908545727, 'fraction_numerical': 0.0, 'mean_word_length': 4.539419087136929, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '657672', 'n_tokens_mistral': 397, 'n_tokens_neox': 382, 'n_words': 104}