/**
  * 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());
 }
 /**
  * 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;
 }
 /**
  * Handle the command.
  *
  * @param SendRegistrationEmailCommand $command
  */
 public function handle($command)
 {
     $user = $command->user;
     $user->generateConfirmationToken();
     $this->userRepository->save($user);
     // TODO: Implement based on notifications module
     //        Notifier::make($user->email, 'users.register', [
     //            'name' => $user->getName(),
     //            'confirmation_url' => URL::base() . '/users/confirm/' . $user->confirmation_token
     //        ]);
 }
Exemple #4
0
 /**
  * Setup the required filters necessary for executing a role search request, based on the $input provided.
  *
  * @param $input
  * @return mixed
  */
 public function fromInput(array $input = [])
 {
     $filterCollection = new SearchFilterCollection();
     if (isset($input['keywords'])) {
         $filterCollection->add(KeywordFilter::fromKeywords($input['keywords']));
     }
     $orderFilter = OrderFilter::byInput($input);
     $orderFilter->setDefaultField('users.id');
     $filterCollection->add($orderFilter);
     // @TODO: Only apply this if the user cannot manage accounts (aka, not a tectician)
     $filterCollection->add(new UserAccountFilter());
     $roles = $this->userRepository->getByFilters($filterCollection);
     return $roles;
 }
 /**
  * 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();
 }
 /**
  * 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());
 }
Exemple #8
0
 /**
  * Retrieve a single user based on their slug.
  *
  * @Get("users/{slug}", middleware={"shift.account", "shift.auth"}, as="users.show")
  *
  * @param $slug
  * @return array
  */
 public function getShow($slug)
 {
     $user = $this->userRepository->requireBySlug($slug);
     return $this->respond('shift::users.edit', compact('user'));
 }
 /**
  * Get a list of account a user belongs to.
  *
  * @param $input
  *
  * @return mixed
  */
 public function getUserAccounts($input)
 {
     $queryString = array_key_exists('q', $input) ? $input['q'] : null;
     return $this->userRepository->getAccounts(Auth::user(), $queryString);
 }
Exemple #10
0
 /**
  * Collect and return currently logged in users profile
  *
  * @param int $userId
  *
  * @return mixed
  */
 public function getUserProfile($userId)
 {
     $user = $this->userRepository->getOneBy('id', $userId);
     return $user;
 }