/**
  * Handle the login command.
  *
  * @param \StyleCI\StyleCI\Commands\User\LoginCommand $command
  *
  * @return void
  */
 public function handle(LoginCommand $command)
 {
     $user = User::find($command->id);
     $attributes = ['name' => $command->name, 'email' => $command->email, 'username' => $command->username, 'token' => $command->token];
     if ($user) {
         $user->fill($attributes);
     } else {
         $user = new User(array_merge(['id' => $command->id], $attributes));
         event(new UserHasSignedUpEvent($user));
     }
     $user->save();
     event(new UserHasLoggedInEvent($user));
 }
Beispiel #2
0
 public function testPresentation()
 {
     $user = User::create(['id' => '12345', 'name' => 'Foo Baz', 'username' => 'baz', 'email' => '*****@*****.**', 'token' => str_repeat('a', 40)]);
     $presented = AutoPresenter::decorate($user);
     $this->assertInstanceOf(UserPresenter::class, $presented);
     $this->assertSame(12345, $presented->id);
     $this->assertSame('Foo', $presented->first_name);
     $this->assertSame('https://www.gravatar.com/avatar/1f58cc55c53a9a863f6f2c1fb73d1334?size=200', $presented->gravatar);
 }
Beispiel #3
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function handle()
 {
     $this->info('Checking all user accounts.');
     $count = 0;
     $factory = app(ClientFactory::class);
     foreach (User::all() as $user) {
         try {
             $factory->make($user)->me()->show();
         } catch (Exception $e) {
             $count++;
             $this->error("Bad user: {$user->id}, {$user->name}, {$user->username}, {$user->email}");
         }
     }
     $this->info("Found {$count} bad users.");
 }
Beispiel #4
0
 /**
  * Find all users marked as collaborators to the provided repo.
  *
  * @param \StyleCI\StyleCI\Models\Repo $repo
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function collaborators(Repo $repo)
 {
     return User::whereIn('id', $this->collaborators->get($repo))->get();
 }