Esempio n. 1
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));
     }
 }
Esempio n. 2
0
 public function getTables()
 {
     /** @var Table[] $tables */
     $tables = array(Identity::table(), IdentityProvider::table(), Session::table(), User::table(), UserIdentity::table(), Album::table(), ExifTag::table(), Image::table(), ImageExif::table());
     return $tables;
 }
Esempio n. 3
0
 public function getUsersByIdentityId($identityId)
 {
     $users = User::statement()->innerJoin('? ON ? = ? AND ? = ?', UserIdentity::table(), UserIdentity::columns()->userId, User::columns()->id, UserIdentity::columns()->identityId, $identityId)->query()->fetchAll();
     return $users;
 }