protected function resendVerification(Request $request)
 {
     $this->validate($request, ['email' => 'required|email|exists:users,email,verified_at,NULL'], ['email.exists' => trans('authentication::verification.email_not_found')]);
     $user = $this->userRepository->where('email', '=', $email = $request->input('email'))->firstOrFail();
     $this->dispatch(new CreateEmailVerification($user));
     Flash::success(trans('authentication::verification.sent_to_email', ['email' => $email]));
     return redirect()->route('front::home');
 }
 public function handleProviderCallback($provider, UserRepository $userRepository)
 {
     /** @var User $oauthUser */
     $oauthUser = Socialite::driver($provider)->user();
     $oauthId = $oauthUser->getId();
     $idField = $provider . '_id';
     // if user with the oauth id already exists simply authenticate
     // meaning user has used this provider but may not have authenticated manually before
     // or used any other providers
     if ($user = $userRepository->where($idField, '=', $oauthId)->first()) {
         return $this->authenticateAndSendResponse($user);
     }
     // if email exists then add the provider id to user
     // this means user has authencated manually or other providers before
     if ($user = $userRepository->where('email', '=', $oauthUser->getEmail())->first()) {
         $user->{$idField} = $oauthId;
         // verify if not already verified
         list($saved, $user) = $userRepository->save($user->verify());
     } else {
         $user = $userRepository->createOauthUser($oauthUser, $idField, $oauthId);
     }
     return $this->authenticateAndSendResponse($user);
 }