/** * 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); }
public function handle($request, Closure $next) { if (Auth::guest() || Auth::user()->perfil != 'Cozinheiro') { return redirect('/'); } return $next($request); }
/** * 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; }
/** * 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); }
public function register() { if (Auth::guest()) { return view('auth.login'); } return view('auth.register'); }
/** * 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); }
public function handle($request, Closure $next) { if (Auth::guest()) { return redirect('auth/login')->with('message', '请先登陆'); } return $next($request); }
/** * @param int $userId * @return bool */ public function isAdmin($userId) { if (Auth::guest()) { return false; } return Auth::user()->is_admin == 1; }
/** * @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); })]; }
/** * 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 != "*****@*****.**") { return Redirect::to('/'); } } else { return Redirect::to('/'); } }); parent::boot($router); }
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); }
public function create() { if (Auth::guest()) { return redirect('posts'); } return view('posts.create'); }
/** * 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); }
/** * @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'); }
public function __construct() { if (!Auth::guest()) { $user_id = Auth::user()->id; $this->user_id = $user_id; } }
public function index() { if (Auth::guest()) { return view('pages.home'); } //Check to make sure gender and names are populated $user = Auth::user(); $fields = ['first_name' => $user->first_name, 'last_name' => $user->last_name, 'gender' => $user->gender]; $validation = Validator::make($fields, User::$baseRules); if (!$validation->passes()) { return redirect('user/name-and-gender'); } //Check to make sure user has choson categories if (!$this->categoryAccount->where('user_id', $user->id)->first()) { return redirect('user/categories'); } $chosenCategories = $this->categoryAccount->where('user_id', Auth::user()->id)->orderByRaw('RAND()')->get(); //Get one random task for the "one for the road" $oneForTheRoad = array(); foreach ($chosenCategories as $category) { $events = $this->event->where('type', $category->category_id)->orderByRaw('RAND()')->get(); foreach ($events as $event) { if (!$this->eventUser->where('event_id', $event->id)->where('user_id', Auth::user()->id)->first() && !$this->eventUser->where('user_id', Auth::user()->id)->where('created_at', '<=', date('Y-m-d 24:00:00'))->where('created_at', '>=', date('Y-m-d 00:00:00'))->where('complete', 1)->first()) { array_push($oneForTheRoad, ['id' => $event->id, 'name' => $event->name, 'description' => $event->description, 'class' => 'active']); } else { array_push($oneForTheRoad, ['id' => '0', 'name' => 'None for today!', 'description' => 'One for the road has completed', 'class' => 'inactive']); } } } $category = $this->category; return view('pages.dashboard', compact('category', 'chosenCategories', 'oneForTheRoad')); }
/** * 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('/admin/login'); } return $next($request); }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { if (!Auth::guest()) { return redirect()->to('account/' . \Auth::id()); } return \View::make('session.create'); }
/** * Renders the project creation view if user is logged in * * @return mixed */ public function createForm() { if (Auth::guest()) { return redirect('/login'); } return view('project.create'); }
/** * 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()->admin) { return $next($request); } return redirect('profile'); }
/** * 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()) { return redirect('login'); } return $next($request); }
protected function isUserAuthenticated() { if (Auth::guest()) { return false; } return true; }
/** * 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()->role == 2) { return $next($request); } return redirect('home')->with('status', 'Sorry !You do not have Authority to Aceess'); }
/** * 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() && !$request->user()->isAnAdmin()) { return redirect('/'); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next, $scopesString = null) { if (Auth::guest()) { parent::handle($request, $next, $scopesString = null); } return $next($request); }
/** * 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()->username != $request->user()->username) { return redirect('/'); } return $next($request); }
/** * Constructor. */ public function __construct() { if (Auth::guest()) { \Auth::login(User::first()); } $this->currentUser = \Auth::user(); }
/** * Show view for creating a new article * * @return \Illuminate\View\View */ public function create() { if (Auth::guest()) { return redirect('articles'); } $tags = Tag::lists('name', 'id'); return view('articles.create', compact('tags')); }
/** * @test */ public function it_allows_user_to_logout() { $user = factory(User::class)->create(); $this->actingAs($user)->visit('/')->see('Logout'); $this->assertFalse(Auth::guest(), 'User is not logged in'); $this->actingAs($user)->post('/logout')->assertRedirectedTo('/'); $this->assertTrue(Auth::guest(), 'User is still authenticated'); }
/** * handles POST requests for comments * * @param $article * @param Request $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function comment($article, Request $request) { $this->validate($request, ['name' => 'required|max:40', 'body' => 'required', 'email' => 'required|email', 'url' => 'url']); $r = $request->all(); $r["user_id"] = Auth::guest() ? "0" : Auth::User()->id; $article->comments()->create($r); return redirect('articles/' . $article->id); }