mirror of
https://github.com/wallabag/wallabag.git
synced 2025-01-26 08:38:09 +00:00
feat: use session instead of referer for redirects
This commit is contained in:
parent
f9c5403529
commit
13bd448e01
3 changed files with 13 additions and 18 deletions
|
@ -626,7 +626,7 @@ class ConfigController extends Controller
|
|||
$em->persist($user);
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($request->headers->get('referer'));
|
||||
return $this->redirect($request->getSession()->get('prevUrl'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -110,9 +110,7 @@ class EntryController extends Controller
|
|||
$em->flush();
|
||||
}
|
||||
|
||||
$redirectUrl = $this->get(Redirect::class)->to($request->headers->get('referer'));
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
return $this->redirect($this->get(Redirect::class)->to($request->getSession()->get('prevUrl')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -379,6 +377,7 @@ class EntryController extends Controller
|
|||
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',
|
||||
|
@ -443,9 +442,7 @@ class EntryController extends Controller
|
|||
$message
|
||||
);
|
||||
|
||||
$redirectUrl = $this->get(Redirect::class)->to($request->headers->get('referer'));
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
return $this->redirect($this->get(Redirect::class)->to($request->getSession()->get('prevUrl')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -473,9 +470,7 @@ class EntryController extends Controller
|
|||
$message
|
||||
);
|
||||
|
||||
$redirectUrl = $this->get(Redirect::class)->to($request->headers->get('referer'));
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
return $this->redirect($this->get(Redirect::class)->to($request->getSession()->get('prevUrl')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -509,10 +504,9 @@ class EntryController extends Controller
|
|||
'flashes.entry.notice.entry_deleted'
|
||||
);
|
||||
|
||||
// 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);
|
||||
|
||||
// don't redirect user to the deleted entry
|
||||
$prev = $request->getSession()->get('prevUrl');
|
||||
$to = (1 !== preg_match('#' . $url . '$#i', $prev) ? $prev : null);
|
||||
$redirectUrl = $this->get(Redirect::class)->to($to);
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
|
@ -612,6 +606,7 @@ class EntryController extends Controller
|
|||
$repository = $this->get(EntryRepository::class);
|
||||
$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 = [];
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class TagController extends Controller
|
|||
$em->flush();
|
||||
}
|
||||
|
||||
$redirectUrl = $this->get(Redirect::class)->to($request->headers->get('referer'), '', true);
|
||||
$redirectUrl = $this->get(Redirect::class)->to($request->getSession()->get('prevUrl'), '', true);
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ class TagController extends Controller
|
|||
$form = $this->createForm(RenameTagType::class, new Tag());
|
||||
$form->handleRequest($request);
|
||||
|
||||
$redirectUrl = $this->get(Redirect::class)->to($request->headers->get('referer'), '', true);
|
||||
$redirectUrl = $this->get(Redirect::class)->to($request->getSession()->get('prevUrl'), '', true);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$newTag = new Tag();
|
||||
|
@ -227,7 +227,7 @@ class TagController extends Controller
|
|||
|
||||
$em->flush();
|
||||
|
||||
return $this->redirect($this->get(Redirect::class)->to($request->headers->get('referer'), '', true));
|
||||
return $this->redirect($this->get(Redirect::class)->to($request->getSession()->get('prevUrl'), '', true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,6 +253,6 @@ class TagController extends Controller
|
|||
|
||||
$redirectUrl = $this->get(Redirect::class)->to($request->headers->get('referer'), '', true);
|
||||
|
||||
return $this->redirect($redirectUrl);
|
||||
return $this->redirect($this->get(Redirect::class)->to($request->getSession()->get('prevUrl'), '', true));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue