本文整理汇总了PHP中App\Http\Controllers\Log::critical方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::critical方法的具体用法?PHP Log::critical怎么用?PHP Log::critical使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\Log
的用法示例。
在下文中一共展示了Log::critical方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleProviderCallback
/**
* Obtain the user information from Provider.
*
* @param string $provider
* @param Socialite|SocialiteManager $socialite
* @param User $userModel
*
* @throws UnprocessableEntityException
*
* @return ApiResponse
*/
public function handleProviderCallback($provider, Socialite $socialite, User $userModel)
{
$this->validateProvider($provider);
$socialUser = $socialite->with($provider)->user();
// Verify so we received an email address, if using oAuth credentials
// with Twitter for instance, that isn't whitelisted, no email
// address will be returned with the response.
// See the notes in Spira API doc under Social Login for more info.
if (!$socialUser->email) {
// The app is connected with the service, but the 3rd party service
// is not configured or allowed to return email addresses, so we
// can't process the data further. Let's throw an exception.
\Log::critical('Provider ' . $provider . ' does not return email.');
throw new UnprocessableEntityException('User object has no email');
}
// Parse the social user to fit within Spira's user model
$socialUser = ParserFactory::parse($socialUser, $provider);
// Get or create the Spira user from the social login
try {
$user = $userModel->findByEmail($socialUser->email);
} catch (ModelNotFoundException $e) {
$user = $userModel->newInstance();
$user->fill(array_merge($socialUser->toArray(), ['user_type' => 'guest']));
$user->save();
}
$socialLogin = new SocialLogin(['provider' => $provider, 'token' => $socialUser->token]);
$user->addSocialLogin($socialLogin);
// Prepare response data
$token = $this->jwtAuth->fromUser($user, ['method' => $provider]);
$returnUrl = $socialite->with($provider)->getCachedReturnUrl() . '?jwtAuthToken=' . $token;
$response = $this->getResponse();
$response->redirect($returnUrl, 302);
return $response;
}