Reputation: 12748
I am trying to make a seamless login to Konakart customer portlet on Liferay, where I have two separate Konakart instances installed (with different .war
-files and different database. This means these two do not know about each other in any way).
What I know is that I could probably make a hook to catch Liferay login event. What after that? I should write a code to access Konakart, but how to do that?
Special point is that there are on same Liferay two Konakart instances and I don't know how to make it in code to add the user to one of them.
Upvotes: 0
Views: 1136
Reputation: 72
We recently implemented this . You will need to modify the BaseAction java file. You can read details at http://www.surekhatech.com/blog/-/blogs/konakart-integration-with-liferay.
Gaurav Shah
Upvotes: 0
Reputation: 11540
Problems with Multi-Store Multiple Databases
You say you have multiple KonaKart deployments and multiples databases.
From the KonaKart documentation:
"KonaKart provides multi-store functionality to enable you to run your stores from a single KonaKart deployment and a single database."
later on it also says:
"In Multi-Store Multiple Databases Mode there is no support for shared customers so the users created are only authorized to log in to their own stores."
If you wanted your portal users to be able to access all your stores and the customer details kept in sync between the stores then it is not recommended to install multiple database installations. However, if you want different sets of users to see different stores then you should be okay.
Integrating Liferay with KonaKart portlet
Liferay implements PortletRequestImpl getRemoteUser() so the portal should pass a userid between the portal and the KonaKart portlet which would be accessible in the portlet using request.getRemoteUser().
According to this thread you should also be able to get other details (including user e-mail) from Liferay's UserServiceUtil from inside your portlet.
KonaKart uses Apache Portal's Struts Bridge and this means that there almost nothing in the way of portlet specific code in the Java part of the application (for the most part this will appear to be a typical Struts 1.2.7 app ). You should be able to use requests and sessions as you usually would and let the bridge worry about the details. That said, special care has to be taken to ensure the JSPs work in the portal container by making use of the Struts Bridge version of the Struts tags (which are portal aware). Using Struts bridge also means that the same application could be run "standalone" (i.e. can be accessed directly outside of the portal container).
It looks like the common identifier between Liferay and KonaKart is going to be the customer e-mail address.
Looking at the KonaKart source code most of the internal processing uses a customer id (an int) and the customer id is acquired through a login method which takes the customer email and a password as arguments. You could set the password for all users to be some secret value known only to the portlet although this would mean you would only be able to access KonaKart via the portal (as the customer wouldn't know their password for the standalone mode).
I've had a little look at the source code for KonaKart-5.5.0.2. It looks like most of the interesting code is in one of two places:
~konakart\custom\appn\src\com\konakart\actions
~konakart\java_api_examples\src\com\konakart\apiexamples
I think you are likely to need to customize the loggedIn method in BaseAction to get your Liferay user details from the request and use the e-mail address to acquire a customer id.
You may also want to be able to do a certain amount of customer registration programmatically. Some of details will need to be set by the customer - e.g. Liferay doesn't usually hold the address details of the portal users. Some of the best places to look are the classes suffixed with "SubmitAction" as these are Struts actions which usually occur after a form submission, some classes worth investigating include:
com.konakart.actions.BaseAction : specifically the method "loggedIn" which checks to see whether we are logged in (and returns the customer id).
com.konakart.actions.EditCustomerSubmitAction : gets called after submitting the edit customer page and shows how to edit customer information.
com.konakart.actions.CustomerRegistrationSubmitAction : gets called after submitting the customer registration page and shows how to register customer information.
com.konakart.actions.ChangePasswordSubmitAction
com.konakart.apiexamples.GetCustomer : get KonaKart customer details if you have their email address
com.konakart.apiexamples.RegisterCustomer : another example of customer registration
I hope this helps
Upvotes: 4