예제 #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');
 }
예제 #2
0
 public function performAction()
 {
     if (!($user = AuthService::getInstance()->getUser())) {
         throw new \Exception('Authenticated user required');
     }
     parent::performAction();
 }
예제 #3
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));
     }
 }
예제 #4
0
 public function performAction()
 {
     ob_end_clean();
     $id = $this->albumId;
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     header("Content-Type: application/json");
     header("Cache-Control: no-store, no-cache, must-revalidate");
     header("Cache-Control: post-check=0, pre-check=0", false);
     header("Pragma: no-cache");
     try {
         $album = Album::findByPrimaryKey($id);
         if (!$album) {
             throw new \Exception('Album not found');
         }
         $user = AuthService::getInstance()->getUser();
         $fileStorage = FileStorage::getInstance();
         $fileStorage->receiveAction($user->urlName . '/' . $album->title);
         foreach (FileStorage::getInstance()->savedFiles as $filePath => $fileUrl) {
             $image = new Image();
             $image->albumId = $album->id;
             $image->path = $filePath;
             $image->url = $fileUrl;
             $image->save();
             $album->imagesCount++;
         }
         $album->save();
         echo '{"jsonrpc" : "2.0", "result" : null, "id" : "id"}';
     } catch (\Exception $exception) {
         $result = array('jsonrpc' => '2.0', 'error' => array('code' => $exception->getCode(), 'message' => $exception->getMessage()), 'id' => 'id');
         echo json_encode($result);
     }
     exit;
 }
예제 #5
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());
 }
예제 #6
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()));
 }
예제 #7
0
 public function performAction()
 {
     if ($user = AuthService::getInstance()->getUser()) {
         $this->response->addContent('Hello, ' . $user->urlName . ' ');
         $this->response->addContent(new Anchor('Sign out', $this->io->makeAnchor(SignOut::createState())));
     }
     //else {
     $this->response->addContent(new Anchor('vk auth', $this->io->makeAnchor(VkAuth::createState())));
     //}
     if (null === $this->action) {
         $this->response->error("Page not found");
         return;
     }
     parent::performAction();
 }
예제 #8
0
 public function performAction()
 {
     if (!($user = AuthService::getInstance()->getUser())) {
         throw new \Exception('Authenticated user required');
     }
     $this->response->success('CATALOGE!');
     /** @var Album[] $albums */
     $albums = Album::statement()->where('? = ?', Album::columns()->userId, $user->id)->query()->fetchAll();
     $this->response->addContent(new Form(Create::createState(), $this->io));
     $details = Details::createState();
     if ($albums) {
         $this->response->addContent(new Rows(Processor::create($albums)->map(function (Album $album) use($details) {
             $row = array();
             $details->albumId = $album->id;
             $anchor = $this->io->makeAnchor($details);
             $row['Title'] = new Anchor($album->title, $anchor);
             $row['Created'] = date('Y-m-d H:i:s', $album->created);
             $row['Updated'] = date('Y-m-d H:i:s', $album->updated);
             $row['Images'] = $album->imagesCount;
             return $row;
         })));
     }
 }
예제 #9
0
<?php

namespace TravelBlog;

use TravelBlog\Auth\AuthService;
AuthService::register('');
예제 #10
0
 public function performAction()
 {
     AuthService::getInstance()->signOut();
     Router::redirect($this->io->makeAnchor(Index::createState()));
 }