public function userPasswordChangeFormSubmitted($button) { $values = $button->getForm()->getValues(); //Nacitanie hodnot formulara if ($values->new_heslo != $values->new_heslo2) { $this->flashRedirect('this', $this->trLang('PasswordChangeForm_new_heslo2_ar'), 'danger'); } $this->clen = $this->user_profiles->find($values->id); //Najdenie clena if (!$this->hasser->CheckPassword($values->heslo, $this->clen->users->password)) { $this->flashRedirect('this', $this->trLang('pass_incorect'), 'danger'); } //Vygeneruj kluc pre zmenu hesla $new_password = $this->hasser->HashPassword($values->new_heslo); $values->new_heslo = 'xxxxx'; //Len pre istotu $values->new_heslo2 = 'xxxxx'; //Len pre istotu try { $this->users->find($this->clen->id_users)->update(['password' => $new_password]); $this->user_profiles->uloz(['modified' => StrFTime("%Y-%m-%d %H:%M:%S", Time())], $values->id); $this->flashMessage($this->trLang('pass_change_ok'), 'success'); } catch (Exception $e) { $this->flashMessage($this->trLang('pass_change_err') . $e->getMessage(), 'danger,n'); } $this->redirect('UserLog:'); }
$form->addText('rok', 'Rok narodenia:', 4, 5)->addRule(Form::RANGE, 'Rok narodenia musí byť v rozsahu od %d do %d', [1900, StrFTime("%Y", Time())]); } if ($user_view_fields["telefon"]) { $form->addText('telefon', 'Telefón:', 20, 20); } if ($user_view_fields["poznamka"]) { $form->addText('poznamka', 'Poznámka:', 50, 250); } if ($user_view_fields["pohl"]) { $form->addSelect('pohl', 'Pohlavie:', ['M' => 'Muž', 'Z' => 'Žena']); } $form->onValidate[] = [$this, 'validateEditUserForm']; $form->addSubmit('uloz', 'Ulož')->setAttribute('class', 'btn btn-success')->onClick[] = [$this, 'editUserFormSubmitted']; $form->addSubmit('cancel', 'Cancel')->setAttribute('class', 'btn btn-default')->setValidationScope(FALSE); return $form; } /** Vlastná validácia * @param Nette\Application\UI\Form $button
public function userPasswordResetFormSubmitted($form) { $values = $form->getValues(); //Nacitanie hodnot formulara if ($values->new_heslo != $values->new_heslo2) { $this->flashRedirect('this', $this->trLang('reset_pass_hesla_err'), 'danger'); } //Vygeneruj kluc pre zmenu hesla $new_password = $this->hasser->HashPassword($values->new_heslo); $values->new_heslo = 'xxxxx'; //Len pre istotu $values->new_heslo2 = 'xxxxx'; //Len pre istotu try { $this->users->find($values->id)->update(['password' => $new_password, 'new_password_key' => NULL, 'new_password_requested' => NULL]); $this->flashRedirect('User:'******'reset_pass_ok'), 'success'); } catch (Exception $e) { $this->flashRedirect('Homepage:', $this->trLang('reset_pass_err') . $e->getMessage(), 'danger,n'); } }