Liferay redirect to user's entered page post login - liferay-6.2

I have created a custom landing page hook in Liferay6.2.
Suppose user enters abc.com/xyz. Then after login he should not be redirected to my custom landing page. Instead he should be redirected to xyz post login.
My landing page should be selected only when he enters abc.com
How to implement this.

This can be fetched using below code in your PostLogin Hook
LastPath lastPath = (LastPath) session.getAttribute(WebKeys.LAST_PATH);

Related

Laravel redirect to intended page after login/register

I am new to Laravel. I am using Laravel's auth controllers for login/register on my website. After login/register, it will redirect to a dashboard. This is fine.
The problem is when the user (not logged in) submits a particular form. The form submission will take the user to a protected page. The auth system will intercept this (if not logged in) and ask for the user to login and the user can sign in. But after the sign in it won't get redirected to the actual destination. Instead, it goes back to the previous page. I tried the redirectto->intended() way in the middleware. It still does not work.
Found the solution. Use HTTP session. I am not sure if this is the best method.
POST the form to a route which doesn't need authentication
Validate and store the form data in the session using the controller
Redirect to the protected route where the auth will intercept and ask the user to login
After successful login, redirect to the original destination page using return redirect()->intended('defaultPage');
Access the form data from session inside the blade view
I am not storing any sensitive data in session. I have no idea how secure this method is.
If you have any suggestions please post.

redirecting page after login in codeigniter

I am quite newbie to codeigniter, I have login system to start with on site, and have 2 scenario:
If user is already logged in, and if clicks on url from other site(different domain), then it will redirect to given link.
If user is not logged in and click on link from other domain then he will first redirect to login page and then he will redirect again to clicked link.
now my first case works but not second, I tried setting a url in session like,
$array['login_redirect'] = current_url();
$this->session->set_userdata($array);
which is giving me correct url
but after login, session data shows login page url as value for login_redirect.
You need to add condition to set current url.
for Example:
$current_url = current_url();
$login_url = 'www.test.com/login'; // Login url of current website
if($current_url != $login_url){
$array['login_redirect'] = $current_url;
$this->session->set_userdata($array);
}
You can save current url in session when user is not logged in and don't do it when user is on login page - then you can read link from session and it will be link to last visited page.
Another solution is to save url to page in cookie when user clicks on link and then you can read it in PHP and redirect user to correct page.
Third solutiuon is to send this link via POST or GET when user is redirected to login page.

Is it possible to get form data after redirect from login page using spring security?

We have an application where user sends form with id's on button click. If the user clicks on the button after session expires, it will redirect to login page. After login i am able to redirect to the post URL, but the form data id's are not present. Is there any way to do this?

Manage Login Redirection in Pyrocms

I need to manage login in such a way that it should redirect the control after successful login to the page which call login method in pyrocms.
By default it return control to Home Page. for example i want to go gallery page but it require user to be logged in so it will redirect control to the login page and now i want to redirect the control back to the gallery page once the user successful logged in.
Finally, i have come with the exact solution which is working correctly for me.
Whenever user try to view the gallery page(restricted page) which require user login, we have to only assign the URL where we want to redirect after successful login in $redirect_to in the controller method:
$this->session->set_userdata('redirect_to',$redirect_to);
Then it will automatically redirect the control to the desired page. Because in the users controller the login function is developed in such a way that:
$redirect_to = $this->input->post('redirect_to') ? $this->input->post('redirect_to') : $this->session->userdata('redirect_to');
Hopefully this will help you sometime

Redirect to originally requested page after Login

I have added an ActionFilter to my MVC site which checks if a user is currently logged on, by checking against a session value, if they are not, they are redirected to a login page. The action filter attribute is added to each controller, so regardless of the page the user tries to view they are redirected to the login view. This bit all works fine.
When the user successfully logs in, I want them to be redirected to the page they were trying to originally access, but I don't how to get my Login Post action to know where to redirect too.
Any help greatly appreciated.
You send along a ReturnUrl when you go to the login view. Then the action method for the login view uses that value to know where to return. The following may help:
ReturnUrl in ASP.NET MVC
as well as this
ASP.NET MVC - CustomeAuthorize filter action using an external website for loggin in the user

Resources