public function filter(Route $route, Request $request) { if ($this->auth->check()) { $config = $this->config->get('c::redirect-login'); $url = $config ? $this->url->to($config) : '/'; return $this->redirect->to($url); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->check()) { return redirect('/admin/home'); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if (!$this->auth->check()) { return new RedirectResponse(route('login')); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->check() && $this->auth->user()['status'] === 'student') { return $next($request); } Session::push('messages', 'danger|Vous devez être étudiant pour accéder à cette page'); return redirect('/'); }
public function handle($request, Closure $next) { if ($this->auth->guest()) { return redirect()->guest('login'); } if ($this->auth->check() && !$this->auth->user()->isAdmin()) { App::abort('403'); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->check()) { if ($this->auth->user()->allowRoutes($request->route()->getName())) { return $next($request); } return response('Forbidden.', 403); } return $next($request); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @return mixed */ public function handle($request, Closure $next) { if (!$this->auth->check()) { flash()->message('Please Log In.'); return new RedirectResponse(url('auth/login')); } if (!$this->auth->user()->is_admin) { flash()->message('Restricted Access!!!'); return new RedirectResponse(url('user/dashboard')); } return $next($request); }
/** * Returns a view with all the blueprints * available, irregardless of the user * who uploaded them * * @param Blueprint $blueprint * @param Guard $guard * * @return $this */ public function blueprints(Blueprint $blueprint, Guard $guard) { $blueprints = $blueprint->select('blueprint.author_name', 'blueprint.user_id', 'blueprint.id', 'blueprint.name', 'blueprint.bc_version', 'blueprint.screenshot', 'blueprint.archive_name', 'blueprint.description', 'blueprint.version')->with(['mods', 'votes' => function ($query) { $query->select('blueprint_user_vote.vote', 'blueprint_user_vote.user_id'); }, 'user' => function ($query) { $query->select('users.id', 'users.name'); }])->orderBy('uploaded_at', 'desc')->paginate(4); $blueprintsAsArray = $blueprints->toArray()['data']; foreach ($blueprintsAsArray as $key => $value) { if (!empty($value['votes'])) { $totalVotes = 0; foreach ($value['votes'] as $vote) { // get total number of votes $totalVotes += $vote['vote']; // check if the current user has voted if ($guard->check()) { if ($vote['user_id'] == $guard->user()->getAuthIdentifier()) { $blueprintsAsArray[$key]['user_has_voted'] = true; $blueprintsAsArray[$key]['user_vote'] = $vote['vote']; } } } $blueprintsAsArray[$key]['total_votes'] = $totalVotes; } else { $blueprintsAsArray[$key]['user_has_voted'] = false; $blueprintsAsArray[$key]['total_votes'] = 0; } } return view('buildcraft.singles')->with(['blueprints' => $blueprints, 'blueprintsAsArray' => $blueprintsAsArray]); }
public function collections(Collection $collection, Guard $guard) { $collections = $collection->with(['votes' => function ($query) { $query->select('collection_user_vote.vote', 'collection_user_vote.user_id'); }, 'user' => function ($query) { $query->select('users.id', 'users.name'); }, 'blueprints' => function ($query) { $query->select('blueprint.id', 'blueprint.name'); }])->paginate(8); $collectionsAsArray = $collections->toArray()['data']; foreach ($collectionsAsArray as $key => $value) { if (!empty($value['votes'])) { $totalVotes = 0; foreach ($value['votes'] as $vote) { // get total number of votes $totalVotes += $vote['vote']; // check if the current user has voted if ($guard->check()) { if ($vote['user_id'] == $guard->user()->getAuthIdentifier()) { $collectionsAsArray[$key]['user_has_voted'] = true; $collectionsAsArray[$key]['user_vote'] = $vote['vote']; } } } $collectionsAsArray[$key]['total_votes'] = $totalVotes; } else { $collectionsAsArray[$key]['user_has_voted'] = false; $collectionsAsArray[$key]['total_votes'] = 0; } } return view('buildcraft.collections')->with(['collections' => $collections, 'collectionsAsArray' => $collectionsAsArray]); }
/** * @param string $topicSlug * @param int $topicId * * @return \Illuminate\Http\RedirectResponse * * @throws \Exception */ public function undo($topicSlug, $topicId) { $topic = $this->topicRepository->find($topicId); if (!$topic) { throw new TopicNotFoundException(); } if (!$topic->has_poll) { throw new PollNotFoundException(); } $poll = $topic->poll; $pollPresenter = app()->make('MyBB\\Core\\Presenters\\Poll', [$poll]); if (!$this->guard->check()) { throw new PollNoGuestUndoException(); } if ($pollPresenter->is_closed) { throw new PollClosedException(); } $vote = $this->pollVoteRepository->findForUserPoll($this->guard->user(), $poll); if (!$vote) { // Error throw new PollNoUndoException(); } $votes = explode(',', $vote->vote); $options = $pollPresenter->options(); foreach ($votes as $option) { if (is_numeric($option) && 0 < $option && $option <= $pollPresenter->num_options()) { $options[$option - 1]['votes']--; } } $poll->update(['options' => $options]); $vote->delete(); return redirect()->route('polls.show', [$topicSlug, $topicId]); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->check()) { $admin = 0; if ($this->auth->user()->admin == 1) { $admin = 1; } if ($admin == 0) { return $this->response->redirectTo('/'); // frontend } return $next($request); } return $this->response->redirectTo('/'); // Go to frontend }
/** * @param int $forumId * @param CreateRequest $createRequest * * @return $this|bool|\Illuminate\Http\RedirectResponse */ public function postCreate($forumId, CreateRequest $createRequest) { // Forum permissions are checked in "CreateRequest" if (!$this->guard->check()) { $captcha = $this->checkCaptcha(); if ($captcha !== true) { return $captcha; } } $poll = null; if ($createRequest->input('add-poll')) { $pollCreateRequest = app()->make('MyBB\\Core\\Http\\Requests\\Poll\\CreateRequest'); $poll = ['question' => $pollCreateRequest->input('question'), 'num_options' => count($pollCreateRequest->options()), 'options' => $pollCreateRequest->options(), 'is_closed' => false, 'is_multiple' => (bool) $pollCreateRequest->input('is_multiple'), 'is_public' => (bool) $pollCreateRequest->input('is_public'), 'end_at' => null, 'max_options' => (int) $pollCreateRequest->input('maxoptions')]; if ($pollCreateRequest->input('endAt')) { $poll['end_at'] = new \DateTime($pollCreateRequest->input('endAt')); } } $topic = $this->topicRepository->create(['title' => $createRequest->input('title'), 'forum_id' => $createRequest->input('forum_id'), 'first_post_id' => 0, 'last_post_id' => 0, 'views' => 0, 'num_posts' => 0, 'content' => $createRequest->input('content'), 'username' => $createRequest->input('username')]); if ($topic) { if ($poll) { $poll['topic_id'] = $topic->id; $this->pollRepository->create($poll); $this->topicRepository->setHasPoll($topic, true); } return redirect()->route('topics.show', ['slug' => $topic->slug, 'id' => $topic->id]); } return redirect()->route('topic.create', ['forumId' => $forumId])->withInput()->withErrors(['content' => trans('errors.error_creating_topic')]); }
/** * @return mixed */ public function myVote() { if (!isset($this->cache['myVote'])) { if ($this->guard->check()) { $this->cache['myVote'] = $this->pollVoteRepository->findForUserPoll($this->guard->user(), $this->wrappedObject); } else { $this->cache['myVote'] = null; } } return $this->cache['myVote']; }
/** * Return the admin login form. * * @param LoginFormBuilder $form * @param Redirector $redirect * @param Repository $config * @param Guard $auth * @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ public function login(LoginFormBuilder $form, Redirector $redirect, Repository $config, Guard $auth) { /** * If we're already logged in * proceed to the dashboard. * * Replace this later with a * configurable landing page. */ if ($auth->check()) { return $redirect->to($config->get('anomaly.module.users::paths.home', 'admin/dashboard')); } return $form->setOption('redirect', $config->get('anomaly.module.users::paths.home', 'admin/dashboard'))->setOption('wrapper_view', 'theme::login')->render(); }
/** * Return the admin login form. * * @param LoginFormBuilder $form * @param Redirector $redirect * @param Repository $config * @param Guard $auth * @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ public function login(NavigationCollection $navigation, LoginFormBuilder $form, Redirector $redirect, Repository $config, Guard $auth) { /** * If we're already logged in * proceed to the dashboard. * * Replace this later with a * configurable landing page. */ if ($auth->check() && ($home = $navigation->home())) { return $redirect->to($config->get($home->getHref())); } return $form->setOption('redirect', 'admin')->setOption('wrapper_view', 'theme::login')->render(); }
/** * Show the application dashboard to the user. * * @return Response */ public function index(Guard $auth) { if ($auth->check()) { $user = $auth->user(); if ($user->niveau == 0) { return view('parents.accueilParents', compact('user')); // Parent } else { if ($user->niveau) { return view('admin.accueilAdmin', compact('user')); // Admin } } } return redirect()->guest('auth/login'); }
/** * Determine if the current user is authenticated. * * @return bool * @static */ public static function check() { return \Illuminate\Auth\Guard::check(); }
/** * @param Guard $auth * @return bool */ public function authorize(Guard $auth) { return $auth->check(); }