本文整理汇总了PHP中App\Http\Controllers\Auth\Auth::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::check方法的具体用法?PHP Auth::check怎么用?PHP Auth::check使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\Auth\Auth
的用法示例。
在下文中一共展示了Auth::check方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logout
/**
* 退出登录
*/
public function logout()
{
if (Auth::check()) {
Auth::logout();
}
return Redirect::to('login');
}
示例2: __construct
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
if (\Auth::check()) {
$this->redirectTo = url(\Auth::user()->slug);
}
$this->middleware('guest', ['except' => 'logout']);
}
示例3: showOptions
/**
* Display the specified resource.
*
* @return Response
*/
public function showOptions()
{
if (\Auth::check()) {
return redirect("/home");
}
return view("login");
}
示例4: __construct
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
if (\Auth::check()) {
return redirect('/');
}
$this->middleware('guest', ['except' => 'getLogout']);
}
示例5: postSecure
public function postSecure()
{
if (\Auth::check()) {
return 1;
} else {
return 0;
}
}
示例6: logout
/**
* Display a login page
*
* @return \Illuminate\Http\Response
*/
public function logout()
{
if (!\Auth::check()) {
return redirect('/login');
}
\Auth::logout();
return redirect('/login');
}
示例7: facebookCallback
public function facebookCallback()
{
$_user = Socialite::driver('facebook')->user();
$user = User::find($_user->getId());
$email = $_user->getEmail() ? $_user->getEmail() : '';
if (!$user) {
$pass = $this->randomPassword();
$user = User::create(['id' => $_user->getId(), 'name' => $_user->getName(), 'email' => $email, 'password' => \Hash::make($pass)]);
$user = User::find($_user->getId());
}
$login = \Auth::login($user);
if (\Auth::check()) {
return redirect('');
}
}
示例8: login
public function login()
{
if (Auth::check()) {
return Redirect::to("/dashboard")->with('message', 'You are all-ready logged in');
}
return view('login');
}
示例9: handleGitHubCallback
/**
* Obtain the user information from GitHub.
*
* @return Response
*/
public function handleGitHubCallback()
{
$gh_user = \Socialite::driver('github')->user();
if (\Auth::check()) {
$user = \Auth::user();
$user->github_id = $gh_user->getId();
$user->github_token = $gh_user->token;
$user->save();
return redirect()->action('Auth\\AuthController@edit')->withMessage('Your GitHub account has been connected!');
}
$user = User::where('github_id', $gh_user->getId())->first();
$name = explode(' ', $gh_user->name);
if ($user) {
\Auth::login($user);
$user->github_token = $gh_user->token;
$user->save();
return redirect()->intended($this->redirectPath());
} else {
$user = User::where('email', $gh_user->getEmail())->first();
if ($user) {
return redirect()->back()->withErrors(['github' => 'You have not authorized your SD Hacks account for GitHub. Please log in to do so.']);
} else {
$user = new User();
$user->email = $gh_user->getEmail();
$user->github_token = $gh_user->token;
$user->github_id = $gh_user->getId();
$user->save();
return view('auth.success');
}
}
}
示例10: getLogout
public function getLogout()
{
$redirect = route('home');
if (\Auth::check()) {
if (\Auth::user()->role_id == 1) {
$redirect = route('adminLogin');
}
if (\Auth::user()->role_id == 2) {
$redirect = route('broadcasterLogin');
}
\Auth::logout();
}
return redirect($redirect);
}
示例11: redirectPath
protected function redirectPath()
{
if (\Auth::check()) {
return \Auth::user()->role->redirect;
}
}