Exemplo n.º 1
0
 /**
  * checks if user exists then creates new if user does not exist.
  */
 private function findOrCreateUser($theUser, $provider)
 {
     $authUser = User::where('uid', $theUser->id)->first();
     $username = isset($theUser->user['first_name']) ? $theUser->user['first_name'] : $theUser->nickname;
     if ($authUser) {
         return $authUser;
     }
     if (User::where('username', $theUser->nickname)->first()) {
         $user = factory(User::class)->make(['username' => $username, 'email' => $theUser->email, 'provider' => $provider, 'uid' => $theUser->id, 'avatar_url' => $theUser->avatar]);
     }
     return User::create(['username' => $username, 'email' => $theUser->email, 'provider' => $provider, 'uid' => $theUser->id, 'avatar_url' => $theUser->avatar]);
 }
Exemplo n.º 2
0
 /**
  * Create User to test login functionality.
  * */
 public function createUser()
 {
     return User::create(['id' => 1, 'name' => 'johndoe', 'email' => '*****@*****.**', 'password' => md5('password')]);
 }