Example #1
0
 /**
  * Handle the command
  *
  * @param UserStoreCommand $command
  * @return mixed
  */
 public function handle($command)
 {
     $newUser = $command->user;
     if (!$this->userRepository->save($newUser)) {
         throw new UserNotStoredException($newUser);
     }
     $this->raise(new UserWasRegistered($newUser));
     $this->dispatchEventsFor($this);
 }
 /**
  * Handle the command
  *
  * @param UserRegisterCommand $command
  * @return UserInterface
  * 
  * @throws UserNotStoredException
  */
 public function handle($command)
 {
     $newUser = $this->userRepository->create();
     $newUser->setIdentifier($command->getFieldValue($this->identifierFieldName));
     $newUser->setEmail(strtolower($command->email));
     $newUser->setPassword($command->password);
     foreach ($this->extraFields as $extraField) {
         $fieldName = $extraField['name'];
         $newUser->setExtra($fieldName, $command->getExtraFieldValue($fieldName));
     }
     $this->raise(new UserWasCreated($newUser));
     $this->dispatchEventsFor($this);
     return $newUser;
 }
Example #3
0
 /**
  * Show a list of all users
  *
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $users = $this->repository->all();
     $response = null;
     $user = Auth::user();
     if (Config::get('auth::publish_user_index') || $user !== null && $user->can('index', $user)) {
         $variables = [];
         $variables['users'] = $users;
         $response = View::make('auth::user.index', $variables);
     } else {
         $response = App::abort(403);
     }
     return $response;
 }
Example #4
0
 /**
  * Handle the command
  *
  * @param UserEditCommand $command
  * @return mixed
  */
 public function handle($command)
 {
     $user = $command->user;
     $changes = [];
     if ($command->emailWasChanged()) {
         $user->setEmail($command->email);
         $changes['email'] = 'Changed';
     }
     if ($command->passwordWasChanged()) {
         $changes['password'] = '******';
         $user->setPassword($command->password);
     }
     foreach ($command->extraFields as $field => $value) {
         if ($command->extraFieldWasChanged($field)) {
             $user->setExtra($field, $value);
         }
     }
     if (!$this->userRepository->save($user)) {
         throw new UserNotStoredException($user);
     }
     return $changes;
 }