In the web application I'm working,
- I've created an organization site which can be accessed by
group/game/home
. - I've made this default landing page after login. By putting this value in the portal-ext.properties file
default.landing.page.path=/group/games/home
- I've also set these two properties to make sure the user is redirected to the default landing page after successfully login.
layout.show.portlet.access.denied=false auth.login.url=/web/guest/login
Now, when I add a new user to the application, the user is created successfully.
But, since the user is not added to the organization, it doesn't have right to access the default landing page.
I have to manually login through admin panel and go to control panel > User and Organisation and then Update Association.
Can someone please help me understand if this can be done at the time of user creation? Is it doable?
NOTE
I'm using Liferay 6.2, Ankit P's suggestion worked for me.
If anyone is using earlier version, Please refer to Prakash K's suggestion.
Note: The following solution is for Liferay 6.1 and for later versions like Liferay 6.2 you directly have a configuration option as explained by Ankit P in his answer
No and Yes.
It cannot be done through configuration alone, but can be achieved with some development effort.
There are various ways to achieve this. The simplest I can think of is with a ModelListener hook, following is a short tutorial:
Define the following in your
liferay-hook.xml
:Create a
portal.properties
file in your src folder and add the following:Create the class
MyCustomUserListener
class by extendingBaseModelListener<User>
:Build and deploy.
onAfterCreate
method would be called.But what will you do for Users who are already created?
Hope this helps.
You can set this association by default from UI starting from Liferay v6.2+.
This setting will automatically associate Users to that particular organization when Users are created.
You can also tick the
Apply to Existing Users
checkbox to update the association for Users already created in database, the User in this case associated when the User logs in to the system first time after this setting.Hope it helps !
After adding user to Liferay. You can use below code to add user to Organization