本文整理汇总了PHP中App\Http\Middleware\Auth::check方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::check方法的具体用法?PHP Auth::check怎么用?PHP Auth::check使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Middleware\Auth
的用法示例。
在下文中一共展示了Auth::check方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!\Auth::check('volunteer')) {
return redirect('/volunteer');
}
return $next($request);
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!(\Auth::check() && !\Auth::user()->isBanned())) {
return redirect('banned')->withErrors('User is banned.');
}
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 (!(\Auth::check() && \Auth::user()->isAdmin())) {
return redirect('/')->withErrors('Access denied to ADMIN functionality!');
}
return $next($request);
}
示例4: handle
public function handle($request, Closure $next)
{
if (\Auth::check() && \Auth::user()->isNotChild() && \Auth::user()->isActive()) {
return $next($request);
}
return redirect('home');
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $roleName)
{
if (Auth::check() && !Auth::user()->hasRole($roleName)) {
return abort(401, 'Unauthorized');
}
return $next($request);
}
示例6: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::check('admin')) {
return redirect('/systems');
}
return $next($request);
}
示例7: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::check()) {
return redirect()->route('home');
}
return $next($request);
}
示例8: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next, $role)
{
if (\Auth::check() && !\Entrust::hasRole($role)) {
return redirect()->back();
}
return $next($request);
}
示例9: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Auth::check()) {
return redirect('/login');
}
return $next($request);
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::check() && Auth::user()->user_typeId == 3) {
return $next($request);
} else {
return redirect('');
}
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::check()) {
$expiresAt = Carbon::now()->addMinutes(5);
Cache::put('user-is-online-' . \Auth::user()->id, true, $expiresAt);
}
return $next($request);
}
示例12: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::check() || \Session::has('lockscreen')) {
return $next($request);
} else {
return redirect('/account/login');
}
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$user = $request->user();
if (!\Auth::check() || !$user->hasRole('super_admin')) {
return redirect("/error");
}
return $next($request);
}
示例14: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$user = Session::get('auth_user');
if (!$user || !\Auth::check()) {
Session::put('url.intended', Request::url());
return redirect('login');
}
return $next($request);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::check()) {
if ($request->id == \Auth::user()->id) {
return redirect('/user');
}
}
return $next($request);
}