title: How to create Laravel 5.1 Custom Authentication driver?
body: <p>I am working in Laravel authentication login using socialite. Now I can able to save data of user from socialite. But now I am facing problem how to authenticate user from gmail, github.</p>
  
  <p>After some research I understood that I need to create custom authentication. I googled but all are Laravel 4.1 topics. If any one work on this please provide your answers.</p>
  
  <p>I already read following topics but I didn't got how to do it?</p>
  
  <p><a href="http://laravel.com/docs/5.1/authentication#social-authentication">http://laravel.com/docs/5.1/authentication#social-authentication</a></p>
  
  <p><a href="http://laravel.com/docs/5.1/providers">http://laravel.com/docs/5.1/providers</a></p>
  
  <p><a href="http://laravel-recipes.com/recipes/115/using-your-own-authentication-driver">http://laravel-recipes.com/recipes/115/using-your-own-authentication-driver</a></p>
  
  <p><a href="http://laravel.io/forum/11-04-2014-laravel-5-how-do-i-create-a-custom-auth-in-laravel-5">http://laravel.io/forum/11-04-2014-laravel-5-how-do-i-create-a-custom-auth-in-laravel-5</a></p>
  
  <p>Update</p>
  
  <pre><code>public function handleProviderCallback() {
      $user = Socialite::with('github')-&gt;user();
      $email=$user-&gt;email;
      $user_id=$user-&gt;id;
  
      //$authUser = User::where('user_id',$user_id)-&gt;where('email', $email)-&gt;first();
      $authUser = $this-&gt;findOrCreateUser($user);
  
      if(Auth::login($authUser, true)) {
          return Redirect::to('user/UserDashboard');
      }   
  }
  
  private function findOrCreateUser($user) {
      if ($authUser = User::where('user_id',$user-&gt;id)-&gt;first()) {
          return $authUser;
      }
  
      return User::create([
          'user_id' =&gt; $user-&gt;id,
          'name' =&gt; $user-&gt;nickname,
          'email' =&gt; $user-&gt;email,
          'avatar' =&gt; $user-&gt;avatar
      ]);
  }
  </code></pre>