Ejemplo n.º 1
0
 public function performAction()
 {
     $identity = Password::findIdentity($this->login, $this->password);
     AuthService::getInstance()->signIn($identity);
     Router::redirect($this->io->makeAnchor(AlbumCommand::createState()));
     $this->response->success('btch');
 }
Ejemplo n.º 2
0
 public function performAction()
 {
     try {
         $identity = new Identity();
         $identity->providerUserId = $this->login;
         $identity->providerId = Password::getProvider()->id;
         $identity->meta = Password::getPasswordHash($this->login, $this->password);
         if ($identity->findSaved()) {
             throw new \Exception('Login is already registered');
         }
         $identity->save();
         $user = new User();
         $user->urlName = $this->login;
         $user->save();
         $userIdentity = new UserIdentity();
         $userIdentity->userId = $user->id;
         $userIdentity->identityId = $identity->id;
         $userIdentity->addedAt = TimeMachine::getInstance()->now();
         $userIdentity->save();
         AuthService::getInstance()->signIn($identity);
         Router::redirect($this->io->makeAnchor(Catalog::createState()));
     } catch (\Exception $exception) {
         $this->response->error($exception->getMessage());
         $this->response->addContent(new Form(RegisterReceive::createState($this->io), $this->io));
     }
 }
Ejemplo n.º 3
0
 public function performAction()
 {
     if ($user = AuthService::getInstance()->getUser()) {
         Router::redirect($this->io->makeAnchor(AlbumCommand::createState()));
     }
     $this->response->addContent(new Heading('Welcome aboard!'));
     $this->response->addContent(LoginForm::create());
 }
Ejemplo n.º 4
0
 public function performAction()
 {
     $user = AuthService::getInstance()->getUser();
     $album = new Album();
     $album->userId = $user->id;
     $album->title = $this->title;
     $album->created = time();
     $album->updated = $album->created;
     $album->imagesCount = 0;
     $album->save();
     Router::redirect($this->io->makeAnchor(Catalog::createState()));
 }
Ejemplo n.º 5
0
 public function performAction()
 {
     AuthService::getInstance()->signOut();
     Router::redirect($this->io->makeAnchor(Index::createState()));
 }