當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Auth::guest方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Facades\Auth::guest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Auth::guest方法的具體用法?PHP Auth::guest怎麽用?PHP Auth::guest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Facades\Auth的用法示例。


在下文中一共展示了Auth::guest方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param Closure|\Closure $next
  * @param $permissions
  * @return mixed
  * @internal param $roles
  * @internal param null|string $guard
  */
 public function handle(Request $request, Closure $next, $permissions)
 {
     if (Auth::guest() || !$request->user()->can(explode('|', $permissions))) {
         abort(403);
     }
     return $next($request);
 }
開發者ID:Matth--,項目名稱:privileges,代碼行數:17,代碼來源:PrivilegesPermissionMiddleware.php

示例2: handle

 public function handle($request, Closure $next)
 {
     if (Auth::guest() || Auth::user()->perfil != 'Cozinheiro') {
         return redirect('/');
     }
     return $next($request);
 }
開發者ID:Brendow007,項目名稱:meuprojeto,代碼行數:7,代碼來源:VerifyIsUserFunc.php

示例3: isUserSessionAuthenticated

 /**
  * Checks whether a user is authentication via the session, essentially a pass through to Laravel's Auth functions.
  * @return bool|string
  */
 private function isUserSessionAuthenticated()
 {
     if (Auth::guest()) {
         return '401-not-authenticated';
     }
     return true;
 }
開發者ID:antarctica,項目名稱:laravel-token-auth,代碼行數:11,代碼來源:AuthFilter.php

示例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()->perfil != "administrador") {
         return redirect()->route('welcome');
     }
     return $next($request);
 }
開發者ID:aureliomachados,項目名稱:social,代碼行數:14,代碼來源:ProtectAdminPages.php

示例5: register

 public function register()
 {
     if (Auth::guest()) {
         return view('auth.login');
     }
     return view('auth.register');
 }
開發者ID:Ristop,項目名稱:valgeranna,代碼行數:7,代碼來源:PagesController.php

示例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() || Auth::user()->perfil != 'Administrador') {
         return redirect('/');
     }
     return $next($request);
 }
開發者ID:Brendow007,項目名稱:meuprojeto,代碼行數:14,代碼來源:VerifyIsUserAdmin.php

示例7: handle

 public function handle($request, Closure $next)
 {
     if (Auth::guest()) {
         return redirect('auth/login')->with('message', '請先登陸');
     }
     return $next($request);
 }
開發者ID:bajian,項目名稱:BiliPusher,代碼行數:7,代碼來源:LoginMiddleware.php

示例8: isAdmin

 /**
  * @param int $userId
  * @return bool
  */
 public function isAdmin($userId)
 {
     if (Auth::guest()) {
         return false;
     }
     return Auth::user()->is_admin == 1;
 }
開發者ID:alfred-nutile-inc,項目名稱:laravel-feature-flag,代碼行數:11,代碼來源:World.php

示例9: getFunctions

 /**
  * @return array
  */
 public function getFunctions()
 {
     return [new Twig_SimpleFunction('user', [$this, 'getUserValue'], ['is_safe' => ['html']]), new Twig_SimpleFunction('user_input', function ($name) {
         return request($name, $this->getUserValue($name));
     }), new Twig_SimpleFunction('link_to_profile', function () {
         $args = func_get_args();
         if (is_array($args[0])) {
             $userId = isset($args['user_id']) ? $args['user_id'] : $args['id'];
             $name = isset($args['user_name']) ? $args['user_name'] : $args['name'];
             $isActive = $args['is_active'];
             $isBlocked = $args['is_blocked'];
         } else {
             $userId = array_shift($args);
             $name = array_shift($args);
             $isActive = array_shift($args);
             $isBlocked = array_shift($args);
         }
         $attributes = ['data-user-id' => $userId];
         if ($isBlocked || !$isActive) {
             $attributes['class'] = 'del';
         }
         return link_to_route('profile', $name, $userId, $attributes);
     }, ['is_safe' => ['html']]), new Twig_SimpleFunction('user_photo', function ($photo) {
         return $photo ? asset('storage/photo/' . $photo) : asset('img/avatar.png');
     }), new Twig_SimpleFunction('can', function ($ability, $policy) {
         return Auth::guest() ? false : policy($policy)->{$ability}(auth()->user(), $policy);
     })];
 }
開發者ID:furious-programming,項目名稱:coyote,代碼行數:31,代碼來源:User.php

示例10: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->filter('auth', function () {
         if (Auth::guest()) {
             if (Request::ajax()) {
                 return Response::make('Unauthorized', 401);
             } else {
                 return Redirect::guest('/');
             }
         }
     });
     $router->filter('auth.basic', function () {
         return Auth::basic();
     });
     $router->filter('guest', function () {
         if (Auth::check()) {
             return Redirect::to('/');
         }
     });
     $router->filter('admin', function () {
         if (Auth::check()) {
             if (Auth::user()->email != "ceesco53@gmail.com") {
                 return Redirect::to('/');
             }
         } else {
             return Redirect::to('/');
         }
     });
     parent::boot($router);
 }
開發者ID:siparker,項目名稱:ribbbon,代碼行數:36,代碼來源:RouteServiceProvider.php

示例11: check

 public function check()
 {
     $user = Auth::user();
     if (Auth::check()) {
         if ($user->can('edit_all')) {
             if (Auth::guest()) {
                 echo "ini guest<br>";
                 dd(Auth::guest());
             } else {
                 if (Auth::user()) {
                     echo "ini user " . $user->id . "<br>";
                     dd(Auth::user());
                 } else {
                     echo "ini di check<br>";
                     dd(Auth::check());
                 }
             }
         } else {
             return redirect('auth/login')->with('status', 'Anda bukan Super Admin');
         }
     } else {
         return redirect('auth/login')->with('status', 'Anda harus login terlebih dahulu');
     }
     //dd($user);
 }
開發者ID:stillAssasin,項目名稱:pedulijilbab,代碼行數:25,代碼來源:AuthController.php

示例12: create

 public function create()
 {
     if (Auth::guest()) {
         return redirect('posts');
     }
     return view('posts.create');
 }
開發者ID:furqank786,項目名稱:blog,代碼行數:7,代碼來源:PostsController.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param Closure|\Closure $next
  * @param $roles
  * @return mixed
  * @internal param null|string $guard
  */
 public function handle(Request $request, Closure $next, $roles)
 {
     if (Auth::guest() || !$request->user()->hasRole(explode('|', $roles))) {
         abort(403);
     }
     return $next($request);
 }
開發者ID:Matth--,項目名稱:privileges,代碼行數:16,代碼來源:PrivilegesRoleMiddleware.php

示例14: it_allow_to_verificaiton_after_registration

 /**
  * @test
  */
 public function it_allow_to_verificaiton_after_registration()
 {
     // remove all users
     User::truncate();
     $this->assertNull(User::first());
     // create verified user
     $formUser = factory(User::class, 'form')->make(['verified' => 1, 'password' => bcrypt('passwordOne')]);
     $formUser->save();
     $this->assertTrue(Auth::guest(), 'User is logged in');
     // send reset link
     MailThief::hijack();
     $this->visit('/password/reset')->type($formUser->email, 'email')->press(trans('user::user.reset_password'))->see('alert-success');
     $password_resets = DB::table('password_resets')->where('email', $formUser->email)->first();
     $this->assertNotNull($password_resets);
     // check mail
     $this->assertTrue(MailThief::hasMessageFor($formUser->email));
     $this->assertEquals('Reset Password', MailThief::lastMessage()->subject);
     $emailContent = MailThief::lastMessage()->getBody();
     $this->assertTrue(strpos($emailContent, $password_resets->token) !== false);
     // click link
     $this->visit('/password/reset/' . $password_resets->token)->see(trans('user::user.reset_password'))->type($formUser->email, 'email')->type('passwordTwo', 'password')->type('passwordTwo', 'password_confirmation')->press(trans('user::user.reset_password'))->see('alert-success');
     $this->assertFalse(Auth::guest(), 'User is NOT logged in');
     // check new password
     $passwordCorrect = app('hash')->check('passwordTwo', User::first()->password);
     $this->assertTrue($passwordCorrect, 'Password not equals with bcrypt');
 }
開發者ID:alcodo,項目名稱:alpaca,代碼行數:29,代碼來源:PasswortResetTest.php

示例15: __construct

 public function __construct()
 {
     if (!Auth::guest()) {
         $user_id = Auth::user()->id;
         $this->user_id = $user_id;
     }
 }
開發者ID:bryceadams,項目名稱:Totals-for-Uber,代碼行數:7,代碼來源:PagesController.php


注:本文中的Illuminate\Support\Facades\Auth::guest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。