to() 공개 메소드

Create a new redirect response to the given path.
public to ( string $path, integer $status = 302, array $headers = [], boolean $secure = null ) : Illuminate\Http\RedirectResponse
$path string
$status integer
$headers array
$secure boolean
리턴 Illuminate\Http\RedirectResponse
예제 #1
1
 /**
  * Handle an incoming request.
  *
  * @param Request $request
  * @param Closure $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if (!$request->isSecure()) {
         return $this->redirector->to($request->getRequestUri(), 302, $request->headers->all(), true);
     }
     return $next($request);
 }
예제 #2
1
 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);
     }
 }
예제 #3
1
 protected function makeResponse(Request $request)
 {
     $message = $this->translator->get('c::auth.login-required');
     if ($request->ajax() || $request->isJson() || $request->wantsJson()) {
         return Response::json(['error' => $message], 403);
     } else {
         $url = $this->url->action('anlutro\\Core\\Web\\AuthController@login');
         $intended = $request->getMethod() == 'GET' ? $request->fullUrl() : ($request->header('referer') ?: '/');
         $this->session->put('url.intended', $intended);
         return $this->redirect->to($url)->with('error', $message);
     }
 }
 /**
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$this->authenticator->isAuthenticated()) {
         return $this->redirector->to($this->config->get('littlegatekeeper.authRoute'));
     }
     return $next($request);
 }
예제 #5
0
 /**
  * Get the proper failed validation response for the request.
  *
  * @param  array  $errors
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function response(array $errors)
 {
     if ($this->ajax() || $this->wantsJson()) {
         return new JsonResponse($errors, 422);
     }
     return $this->redirector->to($this->getRedirectUrl())->withInput($this->except($this->dontFlash))->withErrors($errors, $this->errorBag);
 }
 /**
  * Create a new Redirect response.
  *
  * @param RedirectInterface $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function create(RedirectInterface $redirect)
 {
     $parameters = array_merge(array_map(function () {
         return null;
     }, array_flip($this->route->parameterNames())), $this->route->parameters());
     return $this->redirector->to($this->parser->parse($redirect->getTo(), $parameters), $redirect->getStatus(), [], $redirect->isSecure());
 }
 /**
  * @param $gamertag
  * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
  */
 public function select($gamertag)
 {
     $players = destiny()->player($gamertag);
     if ($players->count() == 1) {
         return $this->redirect->to($players->first()->url);
     }
     return $this->view->make('select', ['gamertag' => $gamertag, 'players' => $players]);
 }
예제 #8
0
 /**
  * Redirect to a post's URL.
  *
  * @param PostRepositoryInterface $posts
  * @param Redirector              $redirect
  * @param                         $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function view(PostRepositoryInterface $posts, Redirector $redirect, $id)
 {
     /* @var PostInterface $post */
     $post = $posts->find($id);
     if (!$post->isLive()) {
         return $redirect->to($this->dispatch(new GetPostPath($post)));
     }
     return $redirect->to($post->path());
 }
 /**
  * Redirect to a partial's URL.
  *
  * @param PartialRepositoryInterface $partials
  * @param Redirector                 $redirector
  * @param                            $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function view(PartialRepositoryInterface $partials, Redirector $redirector, $id)
 {
     $first = $partials->first();
     $partial = $partials->find($id);
     // Redirect to home if this is the first partial.
     if ($first && $first->getId() === $partial->getId()) {
         return $redirector->to('/');
     }
     return $redirector->to($partial->path());
 }
 /**
  * Create a new Redirect response.
  *
  * @param RedirectInterface $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function create(RedirectInterface $redirect)
 {
     $parameters = array_merge(array_map(function () {
         return null;
     }, array_flip($this->route->parameterNames())), $this->route->parameters());
     if (!starts_with($url = $redirect->getTo(), ['http://', 'https://', '//'])) {
         $url = $this->url->to($redirect->getTo(), [], $redirect->isSecure());
     }
     return $this->redirector->to(rtrim($this->parser->parse($url, $parameters), '/'), $redirect->getStatus());
 }
예제 #11
0
 /**
  * Redirect elsewhere.
  *
  * @param PageRepositoryInterface $pages
  * @param Redirector              $redirector
  * @param Route                   $route
  * @return \Illuminate\Http\RedirectResponse|void
  */
 public function redirect(PageRepositoryInterface $pages, Redirector $redirector, Route $route)
 {
     if ($to = array_get($route->getAction(), 'anomaly.module.pages::redirect')) {
         return $redirector->to($to, array_get($route->getAction(), 'status', 302));
     }
     /* @var PageInterface $page */
     if ($page = $pages->find(array_get($route->getAction(), 'anomaly.module.pages::page', 0))) {
         return $redirector->to($page->getPath(), array_get($route->getAction(), 'status', 302));
     }
     abort(404);
 }
예제 #12
0
 /**
  * Redirect to a page's URL.
  *
  * @param PageRepositoryInterface $pages
  * @param Redirector              $redirect
  * @param                         $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function view(PageRepositoryInterface $pages, Redirector $redirect, $id)
 {
     /* @var PageInterface $page */
     $page = $pages->find($id);
     if (!$page->isEnabled()) {
         return $redirect->to('pages/preview/' . $page->getStrId());
     }
     if ($page->isHome()) {
         return $redirect->to('/');
     }
     return $redirect->to($page->getPath());
 }
 /**
  * Show the login form
  *
  * @return mixed
  */
 public function postIndex()
 {
     // Pick up the honeypot field to stop bots, return to the login screen, no message
     if ($this->request->get('potter')) {
         return $this->redirect->to('auth/login')->withInput();
     }
     if (!$this->validator->with($this->request->all())->passes()) {
         return $this->redirect->to('auth/login')->withErrors($this->validator->errors());
     }
     if ($this->auth->attempt(['username' => $this->request->get('username'), 'password' => $this->request->get('password')])) {
         return $this->redirect->intended('/');
     }
     $this->session->flash('failed', trans('auth.incorrect_username_or_password'));
     return $this->redirect->to('auth/login')->withInput();
 }
예제 #14
0
 /**
  * Connect the current user to Last.fm.
  *
  * @param Redirector $redirector
  * @param Lastfm     $lastfm
  *
  * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
  */
 public function connect(Redirector $redirector, Lastfm $lastfm)
 {
     if (!$lastfm->enabled()) {
         abort(401, 'Koel is not configured to use with Last.fm yet.');
     }
     return $redirector->to('https://www.last.fm/api/auth/?api_key=' . $lastfm->getKey() . '&cb=' . route('lastfm.callback'));
 }
예제 #15
0
 public function postReset()
 {
     $credentials = $this->request->only('email', 'password', 'password_confirmation', 'token');
     $response = $this->password->reset($credentials, function ($user, $password) {
         $user->password = $this->hasher->make($password);
         $user->save();
     });
     switch ($response) {
         case $this->password->INVALID_PASSWORD:
         case $this->password->INVALID_TOKEN:
         case $this->password->INVALID_USER:
             return $this->redirector->back()->with('error', $this->translator->get($response));
         case $this->password->PASSWORD_RESET:
             return $this->redirector->to('/');
     }
 }
 /**
  * Handle the command.
  *
  * @param RedirectRepositoryInterface $redirects
  * @param Redirector                  $redirector
  * @param Parser                      $parser
  * @param Route                       $route
  * @return \Illuminate\Http\RedirectResponse
  */
 public function handle(RedirectRepositoryInterface $redirects, Redirector $redirector, Parser $parser, Route $route)
 {
     $redirect = $redirects->find($this->id);
     $parameters = array_merge(array_map(function () {
         return null;
     }, array_flip($route->parameterNames())), $route->parameters());
     return $redirector->to($parser->parse($redirect->getTo(), $parameters), $redirect->getStatus(), [], $redirect->isSecure());
 }
 /**
  * Report errors to the alerts manager and redirect to a page.
  *
  * @param CheckableInterface $check
  * @param CheckResultInterface $result
  */
 public function handleFailure(CheckableInterface $check, CheckResultInterface $result)
 {
     $response = $this->redirector->to($this->getRedirectUrl())->withInput($this->request->except($this->dontFlash));
     if (count($result->getFailed())) {
         if ($check instanceof Validator) {
             $messages = Std::map(function ($value) {
                 return implode(', ', $value);
             }, $result->getFailed());
             $this->pushValidationAlert($messages);
         } else {
             $this->pushValidationSpecAlert($result);
         }
     }
     if (count($result->getMissing())) {
         $this->pushMissingAlert($result->getMissing());
     }
     throw new HttpResponseException($response);
 }
예제 #18
0
 /**
  * Save the order of the entries.
  *
  * @param SectionCollection $sections
  * @param TableBuilder      $builder
  * @param array             $selected
  */
 public function handle(SectionCollection $sections, Redirector $redirector, TableBuilder $builder, array $selected)
 {
     $prefix = $builder->getTableOption('prefix');
     $edit = array_shift($selected);
     $ids = implode(',', $selected);
     if ($section = $sections->active()) {
         $builder->setTableResponse($redirector->to($section->getHref('edit/' . $edit . '?' . $prefix . 'edit_next=' . $ids)));
     }
 }
 /**
  * Check the authorization of module access.
  *
  * @param  Request  $request
  * @param  \Closure $next
  * @return \Illuminate\Http\RedirectResponse
  */
 public function handle(Request $request, Closure $next)
 {
     if (in_array($request->path(), ['admin/login', 'admin/logout'])) {
         return $next($request);
     }
     if ($request->segment(1) == 'admin' && !$this->authorizer->authorize('anomaly.module.users::general.control_panel')) {
         abort(403);
     }
     if (!$this->authorizer->authorize(array_get($this->route->getAction(), 'anomaly.module.users::permission'))) {
         if ($message = array_get($this->route->getAction(), 'anomaly.module.users::message')) {
             $this->messages->error($message);
         }
         if ($redirect = array_get($this->route->getAction(), 'anomaly.module.users::redirect')) {
             return $this->redirect->to($redirect);
         }
         abort(403);
     }
     return $next($request);
 }
예제 #20
0
 /**
  * Connect the current user to Last.fm.
  *
  * @param Redirector $redirector
  * @param Lastfm     $lastfm
  * @param JWTAuth    $auth
  *
  * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
  */
 public function connect(Redirector $redirector, Lastfm $lastfm, JWTAuth $auth = null)
 {
     abort_unless($lastfm->enabled(), 401, 'Koel is not configured to use with Last.fm yet.');
     $auth = $auth ?: $this->app['tymon.jwt.auth'];
     // A workaround to make sure Tymon's JWTAuth get the correct token via our custom
     // "jwt-token" query string instead of the default "token".
     // This is due to the problem that Last.fm returns the token via "token" as well.
     $auth->parseToken('', '', 'jwt-token');
     return $redirector->to('https://www.last.fm/api/auth/?api_key=' . $lastfm->getKey() . '&cb=' . urlencode(route('lastfm.callback') . '?jwt-token=' . $auth->getToken()));
 }
예제 #21
0
 /**
  * Fired when builder is ready to build.
  *
  * @param RoleRepositoryInterface $roles
  * @param BreadcrumbCollection    $breadcrumbs
  * @param MessageBag              $messages
  * @param Redirector              $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function onReady(RoleRepositoryInterface $roles, BreadcrumbCollection $breadcrumbs, MessageBag $messages, Redirector $redirect)
 {
     $this->setEntry($role = $roles->find($this->getEntry()));
     if ($role->getSlug() === 'admin') {
         $messages->warning('anomaly.module.users::warning.modify_admin_role');
         $this->setFormResponse($redirect->to('admin/users/roles'));
         return;
     }
     $breadcrumbs->add($role->getName(), 'admin/users/roles/edit/' . $role->getId());
     $breadcrumbs->add('anomaly.module.users::breadcrumb.permissions', 'admin/users/roles/permissions/' . $role->getId());
 }
 /**
  * Fired when builder is ready to build.
  *
  * @param UserRepositoryInterface $users
  * @param BreadcrumbCollection    $breadcrumbs
  * @param MessageBag              $messages
  * @param Redirector              $redirect
  * @return \Illuminate\Http\RedirectResponse
  */
 public function onReady(UserRepositoryInterface $users, RoleRepositoryInterface $roles, BreadcrumbCollection $breadcrumbs, MessageBag $messages, Redirector $redirect)
 {
     $this->setEntry($user = $users->find($this->getEntry()));
     if ($user->hasRole($roles->findBySlug('admin'))) {
         $messages->warning('anomaly.module.users::warning.modify_admin_user');
         $this->setFormResponse($redirect->to('admin/users'));
         return;
     }
     $breadcrumbs->add($user->getDisplayName(), 'admin/users/edit/' . $user->getId());
     $breadcrumbs->add('anomaly.module.users::breadcrumb.permissions', 'admin/users/permissions/' . $user->getId());
 }
예제 #23
0
 public function postLogin()
 {
     if ($this->auth->attempt($this->request->only('email', 'password'))) {
         $url = $this->request->get("url");
         if ($url == null) {
             return $this->redirector->route("dashboard");
         }
         return $this->redirector->to($this->request->get("url"));
     }
     return $this->redirector->route('home');
 }
 /**
  * Check the authorization of module access.
  *
  * @param  Request  $request
  * @param  \Closure $next
  * @return \Illuminate\Http\RedirectResponse
  */
 public function handle(Request $request, Closure $next)
 {
     if (in_array($request->path(), ['admin/login', 'admin/logout'])) {
         return $next($request);
     }
     /* @var UserInterface $user */
     $user = $this->auth->user();
     $role = array_get($this->route->getAction(), 'anomaly.module.users::role');
     $redirect = array_get($this->route->getAction(), 'anomaly.module.users::redirect');
     $message = array_get($this->route->getAction(), 'anomaly.module.users::message');
     if ($role && (!$user || !$user->hasAnyRole((array) $role))) {
         if ($message) {
             $this->messages->error($message);
         }
         if ($redirect) {
             return $this->redirect->to($redirect);
         }
         abort(403);
     }
     return $next($request);
 }
 public function index(Redirector $redirect, Repository $config)
 {
     $secret = $this->request->input('twofa');
     $twofa = new Google2FA();
     $valid = $twofa->verifyKey(\Auth::user()->twofa_secret, $secret);
     if ($valid === false) {
         $this->messages->error('Your code was not accepted. Please try again');
     } else {
         $this->request->session()->put('minioak::twofa::authenticated', true);
     }
     return $redirect->to($config->get('anomaly.module.users::paths.home', 'admin/dashboard'));
 }
예제 #26
0
 /**
  * Look for locale=LOCALE in the query string.
  *
  * @param  Request  $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if (defined('LOCALE')) {
         return $next($request);
     }
     if ($locale = $request->get('_locale')) {
         if ($locale) {
             $request->session()->put('_locale', $locale);
         } else {
             $request->session()->remove('_locale');
         }
         return $this->redirect->to($request->path());
     }
     if ($locale = $request->session()->get('_locale')) {
         $this->application->setLocale($locale);
         $this->config->set('_locale', $locale);
     }
     if (!$locale) {
         $this->application->setLocale($this->config->get('streams::locales.default'));
     }
     return $next($request);
 }
예제 #27
0
 /**
  * Fired just after
  * saving the form entry.
  *
  * This is basically a validator
  * but I am putting it here because
  * it's far easier to test being that
  * the disk is being loaded already.
  *
  * @param MountManager $manager
  * @param MessageBag   $messages
  * @param Redirector   $redirector
  */
 public function onSaved(MountManager $manager, MessageBag $messages, Redirector $redirector)
 {
     /* @var DiskFormBuilder $builder */
     $builder = $this->forms->get('disk');
     /* @var DiskInterface $entry */
     $entry = $builder->getFormEntry();
     app()->call('Anomaly\\FilesModule\\Disk\\Listener\\RegisterDisks@handle');
     try {
         $manager->has($entry->path('test.me'));
     } catch (\Exception $e) {
         $messages->error($e->getMessage());
         $this->setFormResponse($redirector->to('admin/files/disks/edit/' . $entry->getId()));
     }
 }
예제 #28
0
 /**
  * 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();
 }
예제 #29
0
 /**
  * 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();
 }
예제 #30
0
 /**
  * Handle the form response.
  *
  * @param FormBuilder $builder
  */
 public function handle(FormBuilder $builder)
 {
     /*
      * If the form already has a response
      * then we're being overridden. Abort!
      */
     if ($builder->getFormResponse()) {
         return;
     }
     $entry = $builder->getFormEntry();
     $actions = $builder->getFormActions();
     $action = $actions->active();
     if ($entry && $entry instanceof Arrayable) {
         $entry = $entry->toArray();
     }
     $redirect = $action->getRedirect();
     if ($redirect instanceof RedirectResponse) {
         $builder->setFormResponse($redirect);
         return;
     }
     if ($redirect === false) {
         return;
     }
     $redirect = $this->parser->parse($redirect, compact('entry'));
     /*
      * If the redirect is null then use the current one.
      */
     if ($redirect === null) {
         $redirect = $this->redirector->back()->getTargetUrl();
     }
     /*
      * If the URL is a closure then call it.
      */
     if ($redirect instanceof \Closure) {
         $redirect = app()->call($redirect, compact('builder'));
     }
     /*
      * Restore the query string prior if
      * we're coming from a table.
      */
     if ($query = $this->session->get('table::' . $redirect)) {
         $redirect = strpos($redirect, '?') ? $redirect . '&' . $query : $redirect . '?' . $query;
     }
     $builder->setFormResponse($this->redirector->to($redirect));
 }