本文整理汇总了PHP中Illuminate\Auth\Guard::guest方法的典型用法代码示例。如果您正苦于以下问题:PHP Guard::guest方法的具体用法?PHP Guard::guest怎么用?PHP Guard::guest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Auth\Guard
的用法示例。
在下文中一共展示了Guard::guest方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
return redirect()->guest('/');
}
if (Auth::user()->role === 'admin' || Auth::user()->role === 'superadmin') {
return $next($request);
}
return redirect()->guest('/');
}
示例2: handle
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
return redirect()->guest('login');
}
if ($this->auth->check() && !$this->auth->user()->isAdmin()) {
App::abort('403');
}
return $next($request);
}
示例3: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->admin->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('connexion');
}
}
return $next($request);
}
示例4: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$action = $request->route()->getAction();
if ($this->auth->guest() || !$this->auth->user()->can($action['permission'])) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->route('admin.login');
}
}
return $next($request);
}
示例5: index
public function index(Guard $guard)
{
if (!$guard->guest()) {
return redirect(route('app.dashboard.index'));
}
return view('layouts.login.index');
}
示例6: logout
/**
* Logout the active user.
*
* @param UserAuthenticator $authenticator
* @param Guard $auth
* @return \Illuminate\Http\RedirectResponse
*/
public function logout(UserAuthenticator $authenticator, Guard $auth)
{
if (!$auth->guest()) {
$authenticator->logout();
}
$this->messages->success($this->request->get('message', 'anomaly.module.users::message.logged_out'));
return $this->response->redirectTo($this->request->get('redirect', '/'));
}
示例7: logout
/**
* Log the user out.
*
* @param UserAuthenticator $authenticator
* @param Guard $auth
* @return \Illuminate\Http\RedirectResponse|Redirector
*/
public function logout(UserAuthenticator $authenticator, Guard $auth)
{
if (!$auth->guest()) {
$authenticator->logout();
}
$this->messages->success('anomaly.module.users::message.logged_out');
return redirect('admin/login');
}
示例8: handle
public function handle($request, Closure $next, $role)
{
if ($this->auth->guest()) {
//未登入
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->route('user.login');
}
} elseif (!$this->checkRoleInheritance(Auth::user(), $role)) {
//權限不足
return redirect()->route('home')->with('warning', '權限不足');
} elseif (empty($this->auth->user()->confirm_at)) {
//未驗證信箱
return redirect()->route('user.resend')->with('warning', '完成信箱驗證方可進入此頁面');
}
return $next($request);
}
示例9: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param $role
* @return mixed
*/
public function handle($request, Closure $next, $permissionName)
{
if ($this->auth->guest()) {
//未登入
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->route('member.login');
}
}
$user = $this->auth->user();
if (empty($user->confirm_at)) {
//未驗證信箱
return redirect()->route('member.resend')->with('warning', '完成信箱驗證方可進入此頁面');
}
//取得權限
$permission = Permission::where('name', '=', $permissionName)->first();
if (!$permission || !$user->can($permissionName)) {
return redirect()->route('home')->with('warning', '權限不足');
}
return $next($request);
}
示例10: guest
/**
* Determine if the current user is a guest.
*
* @return bool
* @static
*/
public static function guest()
{
return \Illuminate\Auth\Guard::guest();
}
示例11: filter
public function filter(Route $route, Request $request)
{
if ($this->auth->guest()) {
return $this->makeResponse($request);
}
}