本文整理匯總了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);
}
示例2: handle
public function handle($request, Closure $next)
{
if (Auth::guest() || Auth::user()->perfil != 'Cozinheiro') {
return redirect('/');
}
return $next($request);
}
示例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;
}
示例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);
}
示例5: register
public function register()
{
if (Auth::guest()) {
return view('auth.login');
}
return view('auth.register');
}
示例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);
}
示例7: handle
public function handle($request, Closure $next)
{
if (Auth::guest()) {
return redirect('auth/login')->with('message', '請先登陸');
}
return $next($request);
}
示例8: isAdmin
/**
* @param int $userId
* @return bool
*/
public function isAdmin($userId)
{
if (Auth::guest()) {
return false;
}
return Auth::user()->is_admin == 1;
}
示例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);
})];
}
示例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);
}
示例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);
}
示例12: create
public function create()
{
if (Auth::guest()) {
return redirect('posts');
}
return view('posts.create');
}
示例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);
}
示例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');
}
示例15: __construct
public function __construct()
{
if (!Auth::guest()) {
$user_id = Auth::user()->id;
$this->user_id = $user_id;
}
}