コード例 #1
0
 /**
  * Handle the command.
  *
  * @param UserActivator $activator
  * @param MessageBag    $messages
  */
 public function handle(UserActivator $activator, MessageBag $messages)
 {
     /* @var UserInterface $user */
     $user = $this->builder->getFormEntry();
     $activator->force($user);
     if (!is_null($message = $this->builder->getFormOption('activated_message'))) {
         $messages->info($message);
     }
 }
コード例 #2
0
 /**
  * Handle the command.
  *
  * @param UserActivator $activator
  * @param MessageBag    $messages
  */
 public function handle(UserActivator $activator, MessageBag $messages)
 {
     /* @var UserInterface $user */
     $user = $this->builder->getFormEntry();
     $activator->send($user, $this->builder->getFormOption('activate_redirect', '/'));
     if (!is_null($message = $this->builder->getFormOption('confirm_message'))) {
         $messages->info($message);
     }
 }
コード例 #3
0
 /**
  * Handle the command.
  *
  * @param UserRepositoryInterface $users
  * @param UserActivator           $activator
  * @param Encrypter               $encrypter
  * @param Request                 $request
  * @return bool
  */
 public function handle(UserRepositoryInterface $users, UserActivator $activator, Encrypter $encrypter, Request $request)
 {
     $code = $request->get('code');
     $email = $request->get('email');
     if (!$code || !$email) {
         return false;
     }
     $code = $encrypter->decrypt($code);
     $email = $encrypter->decrypt($email);
     if (!($user = $users->findByEmail($email))) {
         return false;
     }
     return $activator->activate($user, $code);
 }
コード例 #4
0
 /**
  * Run the seeder.
  */
 public function run()
 {
     $this->users->truncate();
     $admin = $this->roles->findBySlug('admin');
     $user = $this->roles->findBySlug('user');
     /* @var UserInterface $administrator */
     $administrator = $this->users->create(['display_name' => 'Administrator', 'email' => env('ADMIN_EMAIL'), 'username' => env('ADMIN_USERNAME'), 'password' => env('ADMIN_PASSWORD')]);
     /* @var UserInterface $demo */
     $demo = $this->users->create(['display_name' => 'Demo User', 'email' => '*****@*****.**', 'password' => 'password', 'username' => 'demo']);
     $demo->roles()->sync([$user->getId()]);
     $administrator->roles()->sync([$admin->getId()]);
     $this->activator->force($demo);
     $this->activator->force($administrator);
 }
コード例 #5
0
 /**
  * Handle the command.
  *
  * @param StreamsHasInstalled $event
  */
 public function handle(StreamsHasInstalled $event)
 {
     $installers = $event->getInstallers();
     $installers->add(new Installer('Creating the admin user.', function () {
         $credentials = ['display_name' => 'Administrator', 'email' => env('ADMIN_EMAIL'), 'username' => env('ADMIN_USERNAME'), 'password' => env('ADMIN_PASSWORD')];
         if ($user = $this->users->findByUsername(env('ADMIN_USERNAME'))) {
             $user->email = env('ADMIN_EMAIL');
             $user->password = env('ADMIN_PASSWORD');
             $this->users->save($user);
         } else {
             $user = $this->users->create($credentials);
         }
         $this->activator->force($user);
     }));
 }
コード例 #6
0
 /**
  * Handle the form.
  *
  * @param SettingRepositoryInterface $settings
  * @param RegisterFormBuilder        $builder
  * @param UserActivator              $activator
  * @throws \Exception
  */
 public function handle(SettingRepositoryInterface $settings, RegisterFormBuilder $builder, UserActivator $activator)
 {
     if (!$builder->canSave()) {
         return;
     }
     $builder->saveForm();
     // Save the new user.
     /* @var UserInterface $user */
     $user = $builder->getFormEntry();
     $activator->start($user);
     $mode = $settings->value('anomaly.module.users::activation_mode', 'manual');
     if ($mode === 'automatic') {
         $this->dispatch(new HandleAutomaticRegistration($builder));
     } elseif ($mode === 'manual') {
         $this->dispatch(new HandleManualRegistration($builder));
     } elseif ($mode === 'email') {
         $this->dispatch(new HandleEmailRegistration($builder));
     }
 }