add() public méthode

Adds new user.
public add ( $username, $email, $password ) : void
Résultat void
 /**
  * Callback for SignUpForm onSuccess event.
  * @param Form      $form
  * @param ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     try {
         $this->userManager->add($values->email, $values->password);
     } catch (DuplicateNameException $e) {
         $form->addError($e->getMessage());
     }
 }
 public function registerFormSucceeded($form)
 {
     $values = $form->values;
     if ($values->password == $values->password2) {
         $this->userManager->add($values->login, $values->password, $values->email);
         $this->flashMessage('You have been successfully registered.');
     } else {
         $this->flashMessage('Both passwords must match.');
     }
 }
Exemple #3
0
 /**
  * @param Form $form
  * @param $values
  */
 function registerFormSucceeded(Form $form, $values)
 {
     try {
         $this->userManager->add($values->username, $values->password, $values->email, UserManager::ROLE_USER, $values->name);
         $this->flashMessage('Your account has been successfully created. You can now login.', 'success');
         $this->redirect('in');
     } catch (DuplicateNameException $e) {
         $this->flashMessage('User with this username or e-mail address already exists.', 'warning');
     }
 }
 public function formSucceeded($form, $values)
 {
     // $stop();
     $user = $this->userManager->add($values->fullname, $values->role, $values->email, $values->password);
     if ($user == false) {
         $form->addError('Tento email je již používán!');
     } else {
         $this->user->login($values->email, $values->password);
         $this->user->setExpiration('14 days', FALSE);
     }
 }
Exemple #5
0
 public function userFormSucceeded($button)
 {
     $values = $button->getForm()->getValues();
     $id = (int) $this->getParameter('id');
     if ($id) {
         $this->database->table('users')->get($id)->update(array('username' => $values->username, 'password' => Passwords::hash($values->password), 'email' => $values->email));
         $this->flashMessage('User has been updated.');
     } else {
         $this->userManager->add($values->username, $values->password, $values->email);
         $this->flashMessage('User has been added.');
     }
     $this->redirect('Homepage:');
 }
 public function formSucceeded(RegistrationForm $form)
 {
     if ($form['remember']->getValue()) {
         $this->user->setExpiration('14 days', false);
     } else {
         $this->user->setExpiration('20 minutes', true);
     }
     $date = DateTime::createFromFormat('Y-m-d', date("Y-m-d"));
     try {
         $this->manager->add($form['username']->getValue(), $form['password']->getValue(), $form['email']->getValue(), $date);
         $this->user->login($form['username']->getValue(), $form['password']->getValue());
     } catch (Nette\Security\AuthenticationException $e) {
         $form->addError($e->getMessage());
     }
 }
 public function formSucceeded(Form $form, $values)
 {
     try {
         $user = $this->um->add($values->email, $values->password, $values->name);
         if ($user) {
             $this->user->login($values->email, $values->password);
             $this->onSuccess();
         } else {
             $form->addError('Oops! Your account could not be created for some reason :-(');
             $this->redrawControl('form');
         }
     } catch (\App\Model\DuplicateEmailException $e) {
         $form->addError('Sorry, this email address is already registered. Sign in or use another one.');
         $this->redrawControl('form');
     }
 }
Exemple #8
0
 /**
  * @return Form
  */
 public function create(callable $onSuccess)
 {
     $form = $this->factory->create();
     $form->addText('username', 'Pick a username:'******'Please pick a username.');
     $form->addEmail('email', 'Your e-mail:')->setRequired('Please enter your e-mail.');
     $form->addPassword('password', 'Create a password:'******'description', sprintf('at least %d characters', self::PASSWORD_MIN_LENGTH))->setRequired('Please create a password.')->addRule($form::MIN_LENGTH, NULL, self::PASSWORD_MIN_LENGTH);
     $form->addSubmit('send', 'Sign up');
     $form->onSuccess[] = function (Form $form, $values) use($onSuccess) {
         try {
             $this->userManager->add($values->username, $values->email, $values->password);
         } catch (Model\DuplicateNameException $e) {
             $form['username']->addError('Username is already taken.');
             return;
         }
         $onSuccess();
     };
     return $form;
 }
 public function itemFormSucceeded(UI\Form $form, $values)
 {
     $itemId = $this->getParameter('id');
     if ($itemId) {
         $item = $this->database->table()->get($itemId);
         if (!$item) {
             $this->error('Data nebyla nalezena v databázi.', 404);
         } else {
             // todo: upravit ucet
         }
         $this->flashMessage('Změny uloženy.', 'success');
     } else {
         try {
             $this->item->add($values['email'], $values['password']);
         } catch (\Exception $e) {
             $this->flashMessage('Účet se nepodařilo vytvořit, nejspíš už existuje se stejným jménem.', 'danger');
         }
         $this->flashMessage('Účet vytvořen.', 'success');
     }
     $this->redirect('default');
 }