/**
* process the class
*
* @since 3.0.0
*
* @return string
*/
public function process()
{
$specialFilter = new Filter\Special();
/* process post */
$postArray = ['id' => $specialFilter->sanitize($this->_request->getPost('id')), 'password' => $specialFilter->sanitize($this->_request->getPost('password')), 'task' => $this->_request->getPost('task'), 'solution' => $this->_request->getPost('solution')];
/* query user */
$user = Db::forTablePrefix('users')->where(['id' => $postArray['id'], 'status' => 1])->findOne();
/* handle error */
$messageArray = $this->_validate($postArray, $user);
if ($messageArray) {
return $this->_error(['message' => $messageArray]);
}
/* handle success */
$passwordHash = new Hash(Config::getInstance());
$passwordHash->init(uniqid());
$resetArray = ['id' => $user->id, 'password' => $passwordHash->getHash()];
$mailArray = ['name' => $user->name, 'email' => $user->email, 'password' => $passwordHash->getRaw()];
/* reset */
if (!$this->_reset($resetArray)) {
return $this->_error(['message' => $this->_language->get('something_wrong')]);
}
/* mail */
if (!$this->_mail($mailArray)) {
return $this->_error(['message' => $this->_language->get('email_failed')]);
}
return $this->_success();
}