本文整理汇总了PHP中App\Http\Middleware\Auth::guest方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::guest方法的具体用法?PHP Auth::guest怎么用?PHP Auth::guest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Middleware\Auth
的用法示例。
在下文中一共展示了Auth::guest方法的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::guest()) {
return redirect()->route('home');
}
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::guest()) {
\Session::flash('message', 'You are not allowed to be here. First Sign In!');
redirect('/auth');
}
}
示例3: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$uri_segments = $request->segments();
if (!empty($uri_segments) && in_array("api", $uri_segments)) {
return $next($request);
}
if (\Auth::guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('http://login.' . \Config::get('app.domain') . '/');
}
}
$usuario = \Auth::user();
if (!empty($usuario)) {
//Menú de administrador
if ($usuario->hasRole('administrador')) {
\Menu::make('menu_lateral', function ($menu) {
$menu->add('Inicio', 'inicio');
});
}
} else {
\Redirect::to('/error500');
}
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)
{
if (!\Auth::guest() && $request->user()->isBanned()) {
return view('banned.ban');
}
return $next($request);
}
示例5: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$request->id('/login') && \Auth::guest()) {
return redirect('/login');
}
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::guest() || !$request->user()->isAdmin()) {
return redirect('/');
}
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::guest()) {
return redirect(route('auth.loginForm'));
}
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)
{
if (\Auth::guest()) {
return redirect('home');
}
if (!$request->user()->isReferent()) {
return redirect('home');
}
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::guest()) {
return \Redirect::home();
}
if (Entrust::hasRole('admin') || Entrust::hasRole('superadmin') || Entrust::hasRole('leader')) {
return $next($request);
}
return \Redirect::home();
}
示例10: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Auth::guest("admin")) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('systems/login');
}
}
return $next($request);
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
*
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (\Auth::guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
}
// put the intended url into session for return upon login
session()->put('url.intended', url());
return redirect()->route('admin.login');
}
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::guest()) {
} else {
if (!\Request::ajax()) {
$menus = \Auth::user()->generateMenu();
view()->share(['mainMenu' => $menus]);
}
}
view()->share(['title' => config('app.title'), 'instansi' => config('app.instansi')]);
return $next($request);
}
示例13: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->is('admin') or $request->is('admin/*')) {
if (\Auth::guest()) {
return redirect('/')->with('flash_info', 'У вас нет прав доступа.');
}
if (!is_admin_role(\Auth::user())) {
return redirect('/')->with('flash_info', 'У вас нет прав доступа.');
}
}
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)
{
if (\Auth::guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
flash()->error("PLEASE_LOGIN");
return redirect()->guest('auth/login');
}
}
if (!$request->is('dashboard') && !$request->is('/')) {
$page = $request->path();
$myCredentials = session('myCredentials');
$flag = true;
foreach ($myCredentials as $credential_group) {
foreach ($credential_group as $credential) {
$credential_path = $credential['path'];
if (strpos($page, $credential_path) == 0) {
$reg_edit = "~^(?:{$credential_path}/(\\d+)/edit)\$~x";
$reg_create = "~^(?:{$credential_path}/create)\$~x";
$myPermissions = session('myPermissions');
if (preg_match($reg_edit, $page) || preg_match($reg_create, $page)) {
if ($myPermissions[$credential_path]['write'] == 1) {
$flag = false;
break 2;
}
} else {
$flag = false;
break 2;
}
if ($request->isMethod('post')) {
if ($myPermissions[$credential_path]['write'] == 1) {
$flag = false;
break 2;
}
}
}
}
}
if ($flag) {
//Lang::get('general.NO_PERMISSION', ['page' => $page]);
flash()->error("You do not have permission to access {$page}.");
return redirect()->intended('dashboard');
}
}
//\Session::regenerateToken();
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)
{
\Me::setOnline();
if (\Auth::check()) {
$access = \Menu::access()['return'];
if ($access == false) {
return redirect('/');
}
if (!empty(\Session::get('lock')) && \Request::path() != 'lockscreen') {
return redirect('/lockscreen');
}
}
if (\Auth::guest()) {
if (!empty(\Session::get('lock'))) {
\Session::forget('lock');
}
}
return $next($request);
}