Beispiel #1
0
 public function loginWithGoogle(Request $request)
 {
     $code = $request->get('code');
     $googleService = $this->oauth->consumer('Google');
     if (!is_null($code)) {
         $googleService->requestAccessToken($code);
         $result = json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo'), true);
         $cms_user = CmsUser::validateCmsUser($result['email']);
         if (!$cms_user) {
             dd("Not a valid google account");
         }
         Auth::login($cms_user);
         if (Auth::check()) {
             return Redirect::intended('cms/restaurant/index');
         }
     } else {
         $url = $googleService->getAuthorizationUri();
         return redirect((string) $url);
     }
 }