/**
  * Handle the command.
  *
  * @param UserRepositoryInterface $users
  * @return bool
  */
 public function handle(UserRepositoryInterface $users)
 {
     $this->user->activated = true;
     $this->user->activation_code = null;
     $users->save($this->user);
     return true;
 }
示例#2
0
 /**
  * Handle the validation.
  *
  * @param UserRepositoryInterface $users
  * @param                         $value
  * @return bool
  */
 public function handle(UserRepositoryInterface $users, $value)
 {
     if (!$users->findByEmail($value)) {
         return false;
     }
     return true;
 }
 /**
  * Handle the form.
  *
  * @param PermissionFormBuilder   $builder
  * @param UserRepositoryInterface $users
  * @param Redirector              $redirect
  */
 public function handle(PermissionFormBuilder $builder, UserRepositoryInterface $users, Redirector $redirect)
 {
     /* @var UserInterface|EloquentModel $user */
     $user = $builder->getEntry();
     $users->save($user->setAttribute('permissions', array_filter(array_flatten($builder->getFormInput()))));
     $builder->setFormResponse($redirect->refresh());
 }
 /**
  * Handle the command.
  *
  * @param RoleRepositoryInterface $roles
  * @param UserRepositoryInterface $users
  */
 public function handle(RoleRepositoryInterface $roles, UserRepositoryInterface $users)
 {
     $user = $users->findByUsername(env('ADMIN_USERNAME'));
     if (!($role = $roles->findBySlug('admin'))) {
         $role = $roles->create(['en' => ['name' => 'Admin'], 'slug' => 'admin']);
     }
     $user->roles()->attach($role);
 }
 /**
  * Handle the form.
  *
  * @param ForgotPasswordFormBuilder $builder
  * @param UserRepositoryInterface   $users
  * @param UserPassword              $password
  */
 public function handle(ForgotPasswordFormBuilder $builder, UserRepositoryInterface $users, UserPassword $password, Repository $config)
 {
     $user = $users->findByEmail($builder->getFormValue('email'));
     if ($path = $builder->getFormOption('reset_path')) {
         $config->set('anomaly.module.users::paths.reset', $path);
     }
     $password->forgot($user);
     $password->send($user, $builder->getFormOption('reset_redirect'));
 }
 /**
  * Handle the form.
  *
  * @param PermissionFormBuilder   $builder
  * @param UserRepositoryInterface $users
  * @param Redirector              $redirect
  */
 public function handle(PermissionFormBuilder $builder, UserRepositoryInterface $users, Redirector $redirect)
 {
     /* @var UserInterface $user */
     $user = $builder->getEntry();
     $users->save($user->setPermissions(array_keys(array_dot(array_map(function ($values) {
         return array_combine(array_values($values), array_pad([], count($values), true));
     }, array_filter($builder->getFormInput()))))));
     $builder->setFormResponse($redirect->refresh());
 }
 /**
  * Handle the validation.
  *
  * @param UserRepositoryInterface $users
  * @param LoginFormBuilder        $builder
  * @return bool
  */
 public function handle(UserRepositoryInterface $users, LoginFormBuilder $builder)
 {
     $values = $builder->getFormValues();
     if (!($user = $users->findByCredentials($values->all()))) {
         return false;
     }
     $builder->setUser($user);
     return true;
 }
 /**
  * Handle the command.
  *
  * @param UserRepositoryInterface $users
  * @return \Anomaly\UsersModule\User\Contract\UserInterface|null
  */
 public function handle(UserRepositoryInterface $users)
 {
     if (!isset($this->credentials['email'])) {
         return null;
     }
     if (!isset($this->credentials['password'])) {
         return null;
     }
     return $users->findByCredentials($this->credentials);
 }
 /**
  * Fired when builder is ready to build.
  *
  * @param UserRepositoryInterface $users
  * @param BreadcrumbCollection    $breadcrumbs
  * @param MessageBag              $messages
  * @param Redirector              $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function onReady(UserRepositoryInterface $users, RoleRepositoryInterface $roles, BreadcrumbCollection $breadcrumbs, MessageBag $messages, Redirector $redirect)
 {
     $this->setEntry($user = $users->find($this->getEntry()));
     if ($user->hasRole($roles->findBySlug('admin'))) {
         $messages->warning('anomaly.module.users::warning.modify_admin_user');
         $this->setFormResponse($redirect->to('admin/users'));
         return;
     }
     $breadcrumbs->add($user->getDisplayName(), 'admin/users/edit/' . $user->getId());
     $breadcrumbs->add('anomaly.module.users::breadcrumb.permissions', 'admin/users/permissions/' . $user->getId());
 }
 public function handle(UserRepositoryInterface $users, ActivationManager $activations)
 {
     $credentials = ['display_name' => 'Administrator', 'email' => env('ADMIN_EMAIL'), 'username' => env('ADMIN_USERNAME'), 'password' => env('ADMIN_PASSWORD')];
     if ($user = $users->findByUsername(env('ADMIN_USERNAME'))) {
         $user->email = env('ADMIN_EMAIL');
         $user->password = env('ADMIN_PASSWORD');
         $users->save($user);
     } else {
         $user = $users->create($credentials, true);
     }
     $activations->force($user);
 }
示例#11
0
 /**
  * @param StreamsHasInstalled $event
  */
 public function handle(StreamsHasInstalled $event)
 {
     $installers = $event->getInstallers();
     $installers->add(new Installer('Creating the user role.', function () {
         $user = $this->users->findByUsername(env('ADMIN_USERNAME'));
         if (!($role = $this->roles->findBySlug('user'))) {
             $role = $this->roles->create(['en' => ['name' => 'User'], 'slug' => 'user']);
         }
         if (!$user->hasRole($role)) {
             $user->roles()->attach($role);
         }
     }));
 }
 /**
  * Handle the form.
  *
  * @param ForgotPasswordFormBuilder $builder
  * @param UserRepositoryInterface   $users
  * @param UserPassword              $password
  * @param MessageBag                $messages
  * @param Repository                $config
  */
 public function handle(ForgotPasswordFormBuilder $builder, UserRepositoryInterface $users, UserPassword $password, MessageBag $messages, Repository $config)
 {
     if ($builder->hasFormErrors()) {
         return;
     }
     $user = $users->findByEmail($builder->getFormValue('email'));
     if ($path = $builder->getFormOption('reset_path')) {
         $config->set('anomaly.module.users::paths.reset', $path);
     }
     $password->forgot($user);
     $password->send($user, $builder->getFormOption('reset_redirect'));
     $messages->success('anomaly.module.users::message.confirm_reset_password');
 }
示例#13
0
 /**
  * Handle the command.
  *
  * @param UserRepositoryInterface $users
  * @return bool
  */
 public function handle(UserRepositoryInterface $users)
 {
     if (!($user = $users->findByActivationCode($this->code))) {
         return false;
     }
     if ($this->user->getId() !== $user->getId()) {
         return false;
     }
     $this->user->activated = true;
     $this->user->activation_code = null;
     $users->save($this->user);
     return true;
 }
 /**
  * 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);
 }
示例#15
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);
 }
示例#16
0
 /**
  * Handle the command.
  *
  * @param UserRepositoryInterface $users
  * @return bool
  */
 public function handle(UserRepositoryInterface $users)
 {
     $user = $users->findByResetCode($this->code);
     if (!$user) {
         return false;
     }
     if ($user->getId() !== $this->user->getId()) {
         return false;
     }
     $this->user->setAttribute('reset_code', null);
     $this->user->setAttribute('password', $this->password);
     $users->save($this->user);
     return true;
 }
示例#17
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);
     }));
 }
示例#18
0
 /**
  * Handle the command.
  *
  * @param UserRepositoryInterface $users
  * @param Guard                   $auth
  * @return \Anomaly\UsersModule\User\Contract\UserInterface|\Illuminate\Contracts\Auth\Authenticatable|null
  */
 public function handle(UserRepositoryInterface $users, Guard $auth)
 {
     if (is_null($this->identifier)) {
         return $auth->user();
     }
     if (is_numeric($this->identifier)) {
         return $users->find($this->identifier);
     }
     if (filter_var($this->identifier, FILTER_VALIDATE_EMAIL)) {
         return $users->findByEmail($this->identifier);
     }
     if (!is_numeric($this->identifier)) {
         return $users->findByUsername($this->identifier);
     }
     return null;
 }
 /**
  * Handle the form.
  *
  * @param UserRepositoryInterface  $users
  * @param ResetPasswordFormBuilder $builder
  * @param MessageBag               $messages
  * @param UserPassword             $password
  */
 public function handle(UserRepositoryInterface $users, ResetPasswordFormBuilder $builder, MessageBag $messages, UserPassword $password)
 {
     $user = $users->findByEmail($builder->getEmail());
     /**
      * If we can't find the user by the email
      * provided then head back to the form.
      */
     if (!$user) {
         $messages->error(trans('anomaly.module.users::error.reset_password'));
         return;
     }
     /**
      * If we can't successfully reset the
      * provided user then back back to the form.
      */
     if (!$password->reset($user, $builder->getCode(), $builder->getFormValue('password'))) {
         $messages->error(trans('anomaly.module.users::error.reset_password'));
         return;
     }
     $messages->success(trans('anomaly.module.users::success.reset_password'));
 }
 /**
  * Handle the command.
  *
  * @param UserRepositoryInterface $users
  * @return bool
  */
 public function handle(UserRepositoryInterface $users)
 {
     return $users->save($this->user->setAttribute('reset_code', str_random(40)));
 }
 /**
  * Handle the command.
  *
  * @param UserRepositoryInterface $users
  * @return bool
  */
 public function handle(UserRepositoryInterface $users)
 {
     $users->save($this->user->setActivationCode(str_random(40)));
     return true;
 }
示例#22
0
 /**
  * Handle the event.
  *
  * @param UserWasLoggedIn $event
  */
 public function handle(UserWasLoggedIn $event)
 {
     $this->users->touchLastLogin($event->getUser());
 }
 /**
  * Handle the command.
  *
  * @param UserRepositoryInterface $users
  * @return bool
  */
 public function handle(UserRepositoryInterface $users)
 {
     $users->save($this->user->setAttribute('activation_code', str_random(40)));
     return true;
 }
 /**
  * If nothing is posted then
  * the user gets no permissions.
  *
  * @param UserRepositoryInterface $users
  */
 public function onPost(UserRepositoryInterface $users)
 {
     if (!$this->hasPostData() && ($entry = $this->getEntry())) {
         $users->save($entry->setAttribute('permissions', []));
     }
 }
 /**
  * Handle the event.
  */
 public function handle()
 {
     if ($user = $this->auth->user()) {
         $this->users->touchLastActivity($user);
     }
 }