. */ $skip_permissions = true; include_once __DIR__.'/core.php'; use Models\User; use Modules\Emails\Mail; use Modules\Emails\Template; use Notifications\EmailNotification; $token = get('reset_token'); switch (post('op')) { case 'reset': $username = post('username'); $email = post('email'); $database->insert('zz_logs', [ 'username' => $username, 'ip' => get_client_ip(), 'stato' => Auth::getStatus()['failed']['code'], ]); try { $utente = User::where('username', $username)->where('email', $email)->first(); if (!empty($utente)) { $utente->reset_token = secure_random_string(); $utente->save(); $template = (new Template())->getByField('title', 'Reset password', Models\Locale::getPredefined()->id); $mail = Mail::build($utente, $template, $utente->id); $mail->addReceiver($utente->email); $mail->save(); $email = EmailNotification::build($mail); $email->send(); } flash()->info(tr("Se le informazioni inserite corrispondono ai dati di un utente, riceverai a breve un'email all'indirizzo collegato").'.'); } catch (Exception $e) { flash()->error(tr("Errore durante la gestione della richiesta: si prega di contattare l'amministratore").'.'); } redirect(base_path().'/index.php'); exit; case 'update': $password = post('password'); $utente = User::where('reset_token', $token)->first(); if (!empty($utente)) { $utente->password = $password; $utente->reset_token = null; $utente->save(); } flash()->info(tr('Password cambiata!')); redirect(base_path().'/index.php'); exit; } $pageTitle = tr('Reimpostazione password'); include_once App::filepath('include|custom|', 'top.php'); // Controllo se è una beta e in caso mostro un warning if (Auth::isBrute()) { echo '

'.tr('Attenzione').'

'.tr('Sono stati effettuati troppi tentativi di accesso consecutivi!').'

'.tr('Tempo rimanente (in secondi)').': '.(Auth::getBruteTimeout() + 1).'

'; } echo '

'.$pageTitle.'

'; if (empty($token)) { echo '

'.tr("Per reimpostare password, inserisci l'username con cui hai accesso al gestionale e l'indirizzo email associato all'utente").'.
'.tr("Se i dati inseriti risulteranno corretti riceverai un'email dove sarà indicato il link da cui potrai reimpostare la tua password").'.

{[ "type": "text", "label": "'.tr('Username').'", "placeholder": "'.tr('Username').'", "name": "username", "icon-before": "", "required": 1 ]} {[ "type": "email", "label": "'.tr('Email').'", "placeholder": "'.tr('Email').'", "name": "email", "icon-before": "", "required": 1 ]}'; } else { echo '

'.tr('Inserisci la nuova password per il tuo account').':

{[ "type": "password", "label": "'.tr('Password').'", "name": "password", "required": 1, "strength": "#submit-button", "icon-before": "" ]}'; } echo '
'; include_once App::filepath('include|custom|', 'bottom.php');