Redirect after login #722
Replies: 3 comments 5 replies
-
Hello. Thanks for the good suggestion. This feature is very useful for stores where the user adds the product to the shopping cart before entering and must enter. And ... As a temporary solution, do the following: shield/src/Filters/SessionAuth.php Line 78 in a04a544 change as follows: if (!url_is('login')) {
$session = session();
$session->setTempdata('beforeLogginUrl', current_url(), 40);
}
return redirect()->route('login'); Then make the following changes in file Config/Auth.php: public function loginRedirect(): string
{
$session = session();
$url = $session->getTempdata('beforeLogginUrl') ?? setting('Auth.redirects')['login'];
return $this->getUrl($url);
} Obviously, applying the mentioned changes is not correct and principled, however, it is presented to solve the issue. I'm fine with adding this feature, however, wait for the team members to decide. |
Beta Was this translation helpful? Give feedback.
-
any ideas how to do that without changes to shield/src/Filters/SessionAuth.php while it is a vendor? |
Beta Was this translation helpful? Give feedback.
-
@emreozkartal the feature has been added in PR #793 |
Beta Was this translation helpful? Give feedback.
-
Hello everyone,
I hope you're all doing well. I have a suggestion for CI4 Shield that I think would be a useful feature to have.
Currently, users are redirected to the default page after logging in, which can be inconvenient if they were trying to access a specific page before logging in. With this new feature, users can be redirected to the page they were trying to access before logging in, making the user experience more seamless.
If anyone knows of any existing code that could be used to implement this feature, please let me know. Otherwise, I think it would be a great addition to CI4 Shield.
Thank you for your time and consideration.
Beta Was this translation helpful? Give feedback.
All reactions