Exemplo n.º 1
0
 /**
  * Handle the command.
  *
  * @param $command
  */
 public function handle($command)
 {
     $user = $this->userRepository->requireBySlug($command->slug);
     $user->edit($command->firstName, $command->lastName, $command->email, $command->password);
     $this->userRepository->save($user);
     $this->dispatcher->dispatch($user->releaseEvents());
 }
Exemplo n.º 2
0
 /**
  * Handle the command.
  *
  * @param $command
  */
 public function handle($command)
 {
     $role = Role::create(['default' => $command->default]);
     $this->roleRepository->save($role);
     $this->translationService->sync($role, $command->translated);
     $this->permissionsService->sync($role, $command->permissions);
     $this->eventDispatcher->dispatch($role->releaseEvents());
 }
Exemplo n.º 3
0
 /**
  * Handle the command.
  *
  * @param $command
  *
  * @return \Tectonic\Shift\Modules\Identity\Users\Models\User
  */
 public function handle($command)
 {
     $user = User::register($command->firstName, $command->lastName, $command->email, $command->password);
     $this->userRepository->save($user);
     $account = CurrentAccount::get();
     $account->addUser($user);
     $this->eventDispatcher->dispatch($user->releaseEvents());
     return $user;
 }
 /**
  * Creates a new account record, assigns
  *
  * @param $command
  */
 public function handle($command)
 {
     // Create account
     $account = Account::create([]);
     $this->accountRepository->save($account);
     $language = $this->languageRepository->getByCode($command->defaultLanguageCode);
     $account->addLanguage($language);
     $account->addTranslation($language->code, 'name', $command->name);
     $account->addDomain($command->domain);
     $this->dispatcher->dispatch($account->releaseEvents());
 }
 /**
  * Handle switching account
  *
  * @param \Tectonic\Application\Commanding\Command $command
  *
  * @return string
  * @throws \Tectonic\Shift\Modules\Authentication\Exceptions\UserAccountAssociationException
  */
 public function handle($command)
 {
     // 1. Make sure user is associated with account.
     if (!$this->accountUserExists($command->user->id)) {
         throw new UserAccountAssociationException();
     }
     // 2. Create a DB record with unique token, account id and user id (if an existing record doesn't exist)
     $token = $this->createAccountSwitchRecord($command);
     $this->accountRepository->save($token);
     // 3. Release events
     $this->eventDispatcher->dispatch($token->releaseEvents());
     // 4. Generate the URL for the account we're switching to (inclusive of token)
     $domainRecord = $this->domainRepository->getOneBy('account_id', $command->accountId);
     return $this->generateReturnUrl($domainRecord->domain, $token->token);
 }
Exemplo n.º 6
0
 /**
  * Handle the command.
  *
  * @param $command
  */
 public function handle($command)
 {
     // Create account
     $account = Account::install();
     // Add new user record and assign to account
     $user = User::install($command->email, $command->password);
     $this->users->save($user);
     $account->setOwner($user);
     $this->accountRepository->save($account);
     // Set the current account for the request. This is necessary for some other tasks
     CurrentAccount::set($account);
     $language = $this->addLanguage($account, $command->language);
     $account->addUser($user);
     $account->addTranslation($language->code, 'name', $command->name);
     $account->addDomain($command->host);
     // Dispatch all events associated with various objects
     $this->dispatcher->dispatch($account->releaseEvents());
     $this->dispatcher->dispatch($user->releaseEvents());
 }
 /**
  * Handle the command.
  *
  * @param $command
  *
  * @throws \Tectonic\Shift\Modules\Authentication\Exceptions\InvalidAuthenticationCredentialsException
  * @throws \Tectonic\Shift\Modules\Authentication\Exceptions\UserAccountAssociationException
  * @return \Illuminate\Auth\UserInterface|null
  */
 public function handle($command)
 {
     // First check to see if the users credentials are valid.
     $userCredentialsAreValid = $this->authenticate->validate(['email' => $command->email, 'password' => $command->password]);
     // If user credential are invalid, throw exception.
     if (!$userCredentialsAreValid) {
         throw new InvalidAuthenticationCredentialsException();
     }
     // Find out if user has an account id with the current account
     $accountUser = $this->userRepository->getByEmailAndAccount($command->email, CurrentAccount::get());
     // If an account user is found, login and return user
     if ($accountUser) {
         $this->authenticate->login($accountUser, $command->remember);
         $user = $this->authenticate->getUser();
         // Raise an event, and dispatch
         $this->raise(new UserHasAuthenticated($user));
         $this->eventDispatcher->dispatch($this->releaseEvents());
         return $user;
     }
     // Login failed, throw exception
     throw new UserAccountAssociationException();
 }
Exemplo n.º 8
0
 /**
  * Handle the command.
  *
  * @param $command
  */
 public function handle($command)
 {
     $user = User::add($command->firstName, $command->lastName, $command->email, $command->password);
     $this->userRepository->save($user);
     $this->dispatcher->dispatch($user->releaseEvents());
 }
Exemplo n.º 9
0
 /**
  * Transfers an account's ownership to another user.
  *
  * @param Account $account
  * @param UserInterface $user
  * @returns Account
  */
 public function transferOwnership(Account $account, User $user)
 {
     $account->setOwner($user);
     $this->accountRepository->save($account);
     $this->dispatcher->dispatch($account->releaseEvents());
 }