示例#1
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);
         }
     }));
 }
示例#2
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);
     }));
 }
 /**
  * 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);
 }
 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);
 }
示例#5
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;
 }