public function resendTokenValidation()
{
$this->set('user', $this->getUsersTable()->newEntity());
$this->set('_serialize', ['user']);
if (!$this->request->is('post')) {
return;
}
$reference = $this->request->data('reference');
try {
if ($this->getUsersTable()->resetToken($reference, ['expiration' => Configure::read('Users.Token.expiration'), 'checkActive' => true, 'sendEmail' => true, 'emailTemplate' => 'CakeDC/Users.validation'])) {
$this->Flash->success(__d('CakeDC/Users', 'Token has been reset successfully. Please check your email.'));
} else {
$this->Flash->error(__d('CakeDC/Users', 'Token could not be reset'));
}
return $this->redirect(['action' => 'login']);
} catch (UserNotFoundException $ex) {
$this->Flash->error(__d('CakeDC/Users', 'User {0} was not found', $reference));
} catch (UserAlreadyActiveException $ex) {
$this->Flash->error(__d('CakeDC/Users', 'User {0} is already active', $reference));
} catch (Exception $ex) {
$this->Flash->error(__d('CakeDC/Users', 'Token could not be reset'));
}
}