mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-15 18:00:36 +01:00
Merge pull request #6119 from Spoons/feat_referer_to_session_redirect
Fix: Use Session instead of Referrer for Redirection
This commit is contained in:
commit
383dcc5c45
@ -615,7 +615,7 @@ class ConfigController extends AbstractController
|
||||
$this->entityManager->persist($user);
|
||||
$this->entityManager->flush();
|
||||
|
||||
return $this->redirect($request->headers->get('referer'));
|
||||
return $this->redirect($request->getSession()->get('prevUrl'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,7 +128,7 @@ class EntryController extends AbstractController
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
$redirectUrl = $this->redirectHelper->to($request->headers->get('referer'));
|
||||
$redirectUrl = $this->redirectHelper->to($request->getSession()->get('prevUrl'));
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
}
|
||||
@ -390,6 +390,7 @@ class EntryController extends AbstractController
|
||||
public function viewAction(Entry $entry)
|
||||
{
|
||||
$this->checkUserAction($entry);
|
||||
$this->get('session')->set('prevUrl', $this->generateUrl('view', ['id' => $entry->getId()]));
|
||||
|
||||
return $this->render(
|
||||
'@WallabagCore/Entry/entry.html.twig',
|
||||
@ -451,7 +452,7 @@ class EntryController extends AbstractController
|
||||
$message
|
||||
);
|
||||
|
||||
$redirectUrl = $this->redirectHelper->to($request->headers->get('referer'));
|
||||
$redirectUrl = $this->redirectHelper->to($request->getSession()->get('prevUrl'));
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
}
|
||||
@ -481,7 +482,7 @@ class EntryController extends AbstractController
|
||||
$message
|
||||
);
|
||||
|
||||
$redirectUrl = $this->redirectHelper->to($request->headers->get('referer'));
|
||||
$redirectUrl = $this->redirectHelper->to($request->getSession()->get('prevUrl'));
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
}
|
||||
@ -517,8 +518,8 @@ class EntryController extends AbstractController
|
||||
);
|
||||
|
||||
// don't redirect user to the deleted entry (check that the referer doesn't end with the same url)
|
||||
$referer = $request->headers->get('referer');
|
||||
$to = (1 !== preg_match('#' . $url . '$#i', $referer) ? $referer : null);
|
||||
$prev = $request->getSession()->get('prevUrl');
|
||||
$to = (1 !== preg_match('#' . $url . '$#i', $prev) ? $prev : null);
|
||||
|
||||
$redirectUrl = $this->redirectHelper->to($to);
|
||||
|
||||
@ -616,6 +617,7 @@ class EntryController extends AbstractController
|
||||
{
|
||||
$searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : '');
|
||||
$currentRoute = (null !== $request->query->get('currentRoute') ? $request->query->get('currentRoute') : '');
|
||||
$request->getSession()->set('prevUrl', $request->getRequestUri());
|
||||
|
||||
$formOptions = [];
|
||||
|
||||
|
@ -104,7 +104,7 @@ class TagController extends AbstractController
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
$redirectUrl = $this->redirectHelper->to($request->headers->get('referer'), '', true);
|
||||
$redirectUrl = $this->redirectHelper->to($request->getSession()->get('prevUrl'), '', true);
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
}
|
||||
@ -185,7 +185,7 @@ class TagController extends AbstractController
|
||||
$form = $this->createForm(RenameTagType::class, new Tag());
|
||||
$form->handleRequest($request);
|
||||
|
||||
$redirectUrl = $this->redirectHelper->to($request->headers->get('referer'), '', true);
|
||||
$redirectUrl = $this->redirectHelper->to($request->getSession()->get('prevUrl'), '', true);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$newTag = new Tag();
|
||||
@ -257,7 +257,7 @@ class TagController extends AbstractController
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
return $this->redirect($this->redirectHelper->to($request->headers->get('referer'), '', true));
|
||||
return $this->redirect($this->redirectHelper->to($request->getSession()->get('prevUrl'), '', true));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -279,8 +279,7 @@ class TagController extends AbstractController
|
||||
$this->entityManager->remove($tag);
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
$redirectUrl = $this->redirectHelper->to($request->headers->get('referer'), '', true);
|
||||
$redirectUrl = $this->redirectHelper->to($request->getSession()->get('prevUrl'), '', true);
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ class TagControllerTest extends WallabagCoreTestCase
|
||||
|
||||
// We make a first request to set an history and test redirection after tag deletion
|
||||
$client->request('GET', '/view/' . $entry->getId());
|
||||
$entryUri = $client->getRequest()->getUri();
|
||||
$entryUri = $client->getRequest()->getRequestUri();
|
||||
$client->request('GET', '/remove-tag/' . $entry->getId() . '/' . $tag->getId());
|
||||
|
||||
$this->assertSame(302, $client->getResponse()->getStatusCode());
|
||||
|
Loading…
Reference in New Issue
Block a user