/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     User::create(['name' => 'test', 'email' => '*****@*****.**', 'password' => bcrypt('secret'), 'role' => 'user']);
     User::create(['name' => 'testAdmin', 'email' => '*****@*****.**', 'password' => bcrypt('secret'), 'role' => 'admin']);
     factory(User::class, 10)->create();
     factory(User::class, 'admin', 2)->create();
 }
 /**
  * Process request to create user
  * @param  App\Http\Requests\Auth\UserCreation                $request
  * @param  App\Storage\EmailConfirmation\EmailConfirmationRepository $tokens
  * @return Illuminate\Http\RedirectResponse
  */
 public function postCreate(UserCreation $request)
 {
     $valid = $this->tokens->verify($request->email, $request->token);
     if (!$valid) {
         return redirect()->route('home')->withDanger(trans('auth.token_not_valid'));
     }
     User::create(['email' => $request->email, 'username' => $request->username, 'password' => bcrypt($request->password)]);
     $this->tokens->delete($request->email);
     return redirect()->route('auth.signin')->withSuccess("User {$request->username} was created. You can now sign in.");
 }
 public function findOrCreateUser($data)
 {
     $user = User::where('email', $data->email)->first();
     if ($user) {
         $user->google_id = $data->id;
         $user->name = $data->name;
         $user->save();
     } else {
         $user = User::create(['email' => $data->email, 'name' => $data->name, 'username' => str_random(5) . time(), 'password' => bcrypt(str_random(10)), 'google_id' => $data->id]);
     }
     return $user;
 }
 public function findOrCreateUser($data)
 {
     $user = User::where('facebook_id', $data->id)->first();
     if ($user) {
         $user->email = $data->email;
         $user->name = $data->first_name . ' ' . $data->last_name;
         $user->save();
         return $user;
     }
     $user = User::where('email', $data->email)->first();
     if ($user) {
         $user->facebook_id = $data->id;
         $user->name = $data->first_name . ' ' . $data->last_name;
         $user->save();
         return $user;
     }
     return User::create(['email' => $data->email, 'name' => $data->first_name . ' ' . $data->last_name, 'password' => bcrypt(str_random(10)), 'facebook_id' => $data->id]);
 }
 public function test()
 {
     User::create(['email' => self::EMAIL, 'username' => self::USERNAME, 'password' => bcrypt(self::PASSWORD)]);
     $this->visit('/signin')->submitForm('Sign in', ['user' => self::EMAIL, 'password' => self::PASSWORD, 'remember-not' => true])->seePageIs('/')->dontSee('Could not sign you in')->visit('/logout')->see('Bye bye')->visit('/signin')->submitForm('Sign in', ['user' => self::USERNAME, 'password' => self::PASSWORD, 'remember-not' => true])->seePageIs('/')->dontSee('Could not sign you in');
 }