/var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Dashboard
Edit: /var/www/vhosts/ihelp.ro/httpdocs/src/Controller/Dashboard/UsersController.php (2402B)
loadComponent('MailHelp');
$email = $this->userAuth->email;
$user_id = $this->userAuth->id;
$user = $this->Users->find()
->where(['Users.id' => $user_id, 'Users.is_active' => true])
->first();
if (!empty($user)) {
if ($this->request->is(['patch', 'post', 'put'])) {
$to = [];
$token = Security::hash(Security::randomBytes(25));
$randomKey = Security::hash(Security::randomBytes(25));
$user = $this->Users->patchEntity($user, $this->request->getData(), ['validate' => 'newPassword']);
$user->token_change_password = $token;
if ($this->Users->save($user)) {
$to['email'] = $email;
$aLink = Router::url(['prefix' => false, 'controller' => 'Users', 'action' => 'changePassword', $token, $randomKey], true);
$this->MailHelp->sendChangePassword($to, $aLink);
$this->Flash->success('Vei primi un email cu pasii de urmat pentru a schimba parola. Multumim');
return $this->redirect(['prefix' => 'Dashboard', 'controller' => 'Profiles', 'action' => 'edit']);
}
}
}
$this->set(compact('user'));
}
/**
* acceptGdpr method
*/
public function acceptGdpr($uuidUser = null)
{
if (!empty($uuidUser)) {
$user = $this->Users->find()
->where(['Users.id' => $this->userAuth->id, 'Users.uuid' => $uuidUser])
->first();
$data = ['gdpr_active' => true];
if ($this->request->is(['patch', 'post', 'put'])) {
$user = $this->Users->patchEntity($user, $data);
if ($this->Users->save($user)) {
$this->Flash->success(__('Datele au fost salvate cu succes.'));
return $this->redirect($this->referer());
}
$this->Flash->error(__('A apărut o problemă. Vă rugăm să încercați din nou'));
}
}
}
}