public function submitRegisterForm(AppForm $form)
 {
     $data = $form->getValues();
     AuthService::register($data['login'], $data['password']);
     $this->flashMessage('Successfully registered');
     $this->redirect('default');
 }
 public function authenticate(array $credentials)
 {
     $user = AuthService::authenticate($credentials[self::USERNAME], $credentials[self::PASSWORD]);
     if (!$user) {
         throw new \Nette\Security\AuthenticationException('Not authorized user', self::INVALID_CREDENTIAL);
     }
     $data = array('login' => $user->login);
     return new Identity($user->id, array(), $data);
 }