User A ----> has "XYZ" role and has "ABC" as home site User B ---->
has "PQR" role and has "DEF" as home site
Whenever user A logs in I need to redirect him to site "ABC" rather than default guest site.
Whenever user B logs in I need to redirect him to site "DEF" rather than default guest site.
Through hook I have achieved this
hook property:
login.events.post=com.mytest.portal.events.MyLoginPostAction
And then in MyLoginPostAction I have checked the user role and then redirected him to corresponding site.
Now, say user A has subscribed to the blog on any of the site. He receives an emaial containing link to that Blog.
User A is logged out and then he tries to reach that Blog with direct link. Since user A is not logged in, he is redirected to login page.
On log in he is redirected to site "ABC" rather than going to that Blog. This is due to I am redirecting User to home site.
So how can I achieve this scenarioes i.e when user try to access that Blog page when not logged in then on log in he should go to that blog page and when user just try to log in to portal then he should redirect to home site.
You can get lastpath object in your action class by
request.getSession().getAttribute("LAST_PATH")
And based on path value from lastpath object, you can determine where to redirect.
By necessary login by direct link, Liferay set the forward path as url parameter. May be you can read the redirect parameter from request and decide to forward to specific page or not.
Related
I am making a Video Chat app, in which user can share the link of the meeting when another person accesses the meeting link and if not authenticated then I redirect to the login page using passportjs, but when user logins, then it goes to the home page rather than meeting URL, how can I redirect to meeting URL after authentication.
The common solution is to add a query param that holds the redirect path.
const redirectLink = encodeURI(`/my-chat-room.com`); // important to encode the link
res.redirect("/login?redirect=" + redirectLink);
Then you can check in your /login handler method if the redirect parameter exsist and use it to redirect the client.
If it doesn't exist use /home as default.
try it with google:
Get a google app link (like a doc link)
Open an incognito tab and use the link (you will be redirected to Google login page).
Check the URL for the continue query param
Is there any provision like, say for visitor user of web application. he is doing say search or trying any functionality, which is allowed for the visitor user and at certain action need to be logged in and if has no credential then need to sign up and return back to the same action page where he was before login/sign up. Is it possible to handle this at application or session level in mvc 5?
Yes, this is handled for you out of the box when you create a new ASP.NET MVC Project. To try this, do the following:
Create a new ASP.NET MVC 5 Project.
Open the Home Controller, and place an [Authorize] Attribute above the "About" action.
Navigate to the "About" menu option at /About.
You will automatically be redirected to the login page. Note that the login URL now reads "/Account/Login?ReturnUrl=%2FHome%2FAbout". This is how the initiating URL is passed into the login page.
Log into the site. After logging in, note that you are redirected back to the "/About" page that you were trying to initially access.
Of course this is not bullet proof. If you try to register before logging in you will notice that you are no longer redirected back to that initial page, but it is a start.
I have 4 different organization and some users are associated to it. I have separate site for each organization. my requirement is If I am user of organization A , On login I should be able to redirect to my organization site.
eg: localhost:8080/web/org-A/home
How can I achieve this requirement. As per my knowledge I need to create post login hook by which user will get redirected to its own site.
I would like to know if any configuration in poral-ext.property is available by which user can redirect to his own site automatically after login.
I am Using Liferay 6.1CE.
I can able to set my default landing page to a site in control panel.
But in my portal 2 sites are there,two users are there.
For eg: userA is a member of siteA,simularly UserB member of siteB.
How can i redirect the users to their site after login.
What can i do?
I guess 2 sites you mean two communities. Anyway you need to create post login action where you'll check your conditions and redirect where needed.
You can create the Liferay hook for your custom login post action. Please have a look at :
custom action using hook
on how to create the hook.
In the hook, you can identify the looged in user based on your search criteria and redirect to the relevant community.
i have developed a site on drupal 6 and now i want to Block direct access to any node url on my site,how can i Block any user to acces the site and redirect on login page from where they can create a new account if he doesnot have user id and passsword,so any one please help me regarding this.Thanks in advance
If you want to not allow any anonymous users to access content on your site, turn off the permission on the Permissions settings under User Management.
You could then set the default front page to /user so everyone who goes to the site would be greeted with the login screen (and be allowed to register a user, if needed).