本文整理汇总了PHP中Illuminate\Support\Facades\Log::warn方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::warn方法的具体用法?PHP Log::warn怎么用?PHP Log::warn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Log
的用法示例。
在下文中一共展示了Log::warn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: callback
/**
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Laravel\Lumen\Http\Redirector
*/
public function callback(Request $request)
{
$state = $request->get('state');
$sessionState = Session::get('google.oauth2state');
$code = $request->get('code');
if ($request->get('error')) {
$request->session()->flash('error', 'auth.error');
return redirect(route('auth.loginForm'));
}
if (empty($state) || $state !== $sessionState) {
Session::forget('google.oauth2state');
$request->session()->flash('error', 'auth.error');
return redirect(route('auth.loginForm'));
}
$token = $this->provider->getAccessToken('authorization_code', ['code' => $code]);
try {
/** @var GoogleUser $ownerDetails */
$ownerDetails = $this->provider->getResourceOwner($token);
$email = $ownerDetails->getEmail();
// if we already have the email in DB we log the user
if (!$this->repository->exists(['email' => $email])) {
$lastName = $ownerDetails->getLastName();
$firstName = $ownerDetails->getFirstName();
$this->createUser($firstName, $lastName, $email);
}
// we try to logged in the user with the email and the google oauth access token
Input::merge(['client_id' => Config::get('oauth2.web_client.client_id')]);
Input::merge(['client_secret' => Config::get('oauth2.web_client.client_secret')]);
Input::merge(['grant_type' => 'google']);
Input::merge(['username' => $email]);
Input::merge(['password' => $token->getToken()]);
try {
Authorizer::issueAccessToken();
return redirect('/');
} catch (\Exception $e) {
$request->session()->flash('error', 'auth.login_error');
return redirect(route('auth.loginForm'));
}
} catch (ModelNotValid $e) {
$request->session()->flash('error', 'auth.error');
Log::warn($e->getMessage());
return redirect(route('auth.loginForm'));
} catch (\Exception $e) {
$request->session()->flash('error', 'auth.error');
Log::warn($e->getMessage());
return redirect(route('auth.loginForm'));
}
}