Foros de discusión

RE: Development of login portlet

Matt S., modificado hace 11 años.

Development of login portlet

Junior Member Mensajes: 36 Fecha de incorporación: 29/11/12 Mensajes recientes
Hi, I'm new in liferay and I have a problem with development of my own login portlet. My idea is to create an organization as administrator an then create in the home page of the portal a registration form where a guest write his credential ( name, surname, email psw ecc...) and became an user of that organization. How I can do this, in particular how can assign the new user to the organization?
Juan Francisco Ramos, modificado hace 11 años.

RE: Development of login portlet

New Member Mensajes: 7 Fecha de incorporación: 1/06/10 Mensajes recientes
Hi! You must use a hook portlet or an ext portlet to override the original login portlet of Liferay. In the main page of Liferay you have documentation of how to create an ext portlet.

When you have the ext portlet, you must add the functionality to assign the new user to the organization. Use this method:

UserLocalServiceUtil.addOrganizationUsers(organizationId, userIds)

Please look this:

http://www.liferay.com/es/community/forums/-/message_boards/message/12926600

I hope it helps you.
thumbnail
Jan Geißler, modificado hace 11 años.

RE: Development of login portlet

Liferay Master Mensajes: 735 Fecha de incorporación: 5/07/11 Mensajes recientes
Hi Matt!
If I understand you correctly, you want to assign a new User automatically to an Organisation, is that correct?
If so, there are some options you might want to consider:
1. You can assign default sites (not an organization I know, but there is not so much difference in site and organizations if you look a little bit more closely at it) to new user via Control-Panel -> Portal/Settings -> Users and Organizations (right hand menu) and -> Default User Associations
2. You could write a ModelListener and overwrite onAfterCreate(User user) where you could apply your custom Logic. The benefits would be, that you don't have to write a complete login Portlet, just use and canibalize the Login-Portlet from Liferay ;)

Hop I could be of assistance!

So long
Jan
Matt S., modificado hace 11 años.

RE: Development of login portlet

Junior Member Mensajes: 36 Fecha de incorporación: 29/11/12 Mensajes recientes
Hi to both and thank you for the answers emoticon My idea in not to modify the Liferay Login portlet but to create my custom portlet with Liferay IDE.I have found some docs about the method to use for doing it, in particular how to create an user and assign it to an organization but I have a problem with the authentication because I haven't found the appropriate documentation. Can someone give me a link?
thumbnail
Nicolas Tamayo, modificado hace 11 años.

RE: Development of login portlet

Junior Member Mensajes: 29 Fecha de incorporación: 3/10/12 Mensajes recientes
Hi Matt.

I have a question that make to you.

you want know how LIferay make the authentication of the user?
Matt S., modificado hace 11 años.

RE: Development of login portlet

Junior Member Mensajes: 36 Fecha de incorporación: 29/11/12 Mensajes recientes
Hi Nicholas,

yes, it is one of the things I want to know. In simple terms i want create a registration form where a guest can create an account (like login portlet of Liferay).This new account must be assigned to an organization previously created by me in the control panel like administrator. Then the user, if he want to enter in the organization, must authenticate. I don't know how to do this.
I hope you can help me.
Matt S., modificado hace 11 años.

RE: Development of login portlet

Junior Member Mensajes: 36 Fecha de incorporación: 29/11/12 Mensajes recientes
I tried to create an user using this code but I have an exception that I don't understand...the code is


public class Registrazione extends MVCPortlet {
 
	public void processAction(ActionRequest request, ActionResponse response) throws IOException, PortletException{
		ThemeDisplay theme= (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
		 long creatorUserId = theme.getUserId(); // default liferay user
		  long companyId = theme.getCompanyId(); // default company
		  boolean autoPassword = false;
		  String password1 = "";//request.getParameter("psw");
		  String password2 = "";
		  boolean autoScreenName = false;
		  String screenName ="Ayeye" ;//request.getParameter("user");
		  String emailAddress = "hdjshd@hotmail.it";//request.getParameter("email");
		  long facebookId = 0;
		  String openId = "";
		  Locale locale = theme.getLocale();
		  String firstName = "Bo";//request.getParameter("name");
		  String middleName = "";
		  String lastName = "Bo";//request.getParameter("cognome");
		  int prefixId = 0;
		  int suffixId = 0;
		  boolean male = true;    
		  int birthdayMonth = 10;
		  int birthdayDay = 10;
		  int birthdayYear = 2010;
		  String jobTitle = "";
		 
		  long[] groupIds = null;
		  long[] organizationIds = null;
		  long[] roleIds = null;
		  long[] userGroupIds = null;
		 
		  boolean sendEmail = false;
		 
		  
		 
		  try {
			User user = UserLocalServiceUtil.addUser(creatorUserId,
			                                           companyId,
			                                           autoPassword,
			                                           password1,
			                                           password2,
			                                           autoScreenName,
			                                           screenName,
			                                           emailAddress,
			                                           facebookId,
			                                           openId,
			                                           locale,
			                                           firstName,
			                                           middleName,
			                                           lastName,
			                                           prefixId,
			                                           suffixId,
			                                           male,
			                                           birthdayMonth,
			                                           birthdayDay,
			                                           birthdayYear,
			                                           jobTitle,
			                                           groupIds,
			                                           organizationIds,
			                                           roleIds,
			                                           userGroupIds,
			                                           sendEmail,
			                                           ServiceContextFactory.getInstance(request));
		} catch (PortalException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SystemException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}


The error is
com.liferay.portal.DuplicateUserScreenNameException
	at com.liferay.portal.service.impl.UserLocalServiceImpl.validateScreenName(UserLocalServiceImpl.java:5762)
	at com.liferay.portal.service.impl.UserLocalServiceImpl.validate(UserLocalServiceImpl.java:5526)
	at com.liferay.portal.service.impl.UserLocalServiceImpl.addUserWithWorkflow(UserLocalServiceImpl.java:668)
	at com.liferay.portal.service.impl.UserLocalServiceImpl.addUser(UserLocalServiceImpl.java:539)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:122)
	at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:71)
	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
	at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
	at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
	at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:211)
	at $Proxy97.addUser(Unknown Source)
	at com.liferay.portal.service.UserLocalServiceUtil.addUser(UserLocalServiceUtil.java:463)
	at com.test.Registrazione.processAction(Registrazione.java:89)
	at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:70)
	at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
	at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:111)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
	at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
	at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
	at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:534)
	at com.liferay.portlet.InvokerPortletImpl.invokeAction(InvokerPortletImpl.java:579)
	at com.liferay.portlet.InvokerPortletImpl.processAction(InvokerPortletImpl.java:294)
	at com.liferay.portal.action.LayoutAction.processPortletRequest(LayoutAction.java:944)
	at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:688)
	at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:249)
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
	at com.liferay.portal.struts.PortalRequestProcessor.process(PortalRequestProcessor.java:176)
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
	at com.liferay.portal.servlet.MainServlet.callParentService(MainServlet.java:560)
	at com.liferay.portal.servlet.MainServlet.service(MainServlet.java:537)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
	at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:294)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
	at com.liferay.portal.servlet.FriendlyURLServlet.service(FriendlyURLServlet.java:138)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
	at com.liferay.portal.servlet.filters.strip.StripFilter.processFilter(StripFilter.java:335)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
	at com.liferay.portal.servlet.filters.gzip.GZipFilter.processFilter(GZipFilter.java:123)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
	at com.liferay.portal.servlet.filters.secure.SecureFilter.processFilter(SecureFilter.java:294)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
	at com.liferay.portal.servlet.filters.i18n.I18nFilter.processFilter(I18nFilter.java:241)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
	at com.liferay.portal.servlet.filters.autologin.AutoLoginFilter.processFilter(AutoLoginFilter.java:246)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
	at com.liferay.portal.servlet.filters.sso.ntlm.NtlmPostFilter.processFilter(NtlmPostFilter.java:83)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
	at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:80)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
	at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:163)
	at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:216)
	at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:57)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:187)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:738)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:206)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:108)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:167)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:167)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:187)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:95)
	at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:619)

How can I solve it?
thumbnail
Jan Geißler, modificado hace 11 años.

RE: Development of login portlet

Liferay Master Mensajes: 735 Fecha de incorporación: 5/07/11 Mensajes recientes
You already added a User with this particular screen name. You should change it, as Liferay doesn't allow you to have 2 Users with the same screen name.
I still don't understand why you insist on writing your own portlet, when your requirement can easily be met by a model listener with about 20 lines of code...
thumbnail
Nicolas Tamayo, modificado hace 11 años.

RE: Development of login portlet

Junior Member Mensajes: 29 Fecha de incorporación: 3/10/12 Mensajes recientes
Hi Matt.

regarding to the Exception Jan have reason.

in the case that you want create a new Custom Portlet to Login, you must do all the Logic that involves the Creation Process of Liferay User (the funcionality that you already have), this is very simple because you just must use the Service of the Organization (for example: OrganizationLocalServiceUtil). in this case i can´t help you much.

in the case that you want make the Athentication Process; you must use the Login method in the LoginUtil Class, this class you can find it in the portlet-imp.jar, bacauser you can use the PortalClassInvokerClass to make the call to the method. int this case i can help you.

at this link you'll see how to user the PortalClassInvoker
Matt S., modificado hace 11 años.

RE: Development of login portlet

Junior Member Mensajes: 36 Fecha de incorporación: 29/11/12 Mensajes recientes
Hi,
The code I posted before is corret for creating a new user? (don't consider the exception) I ask this because I found other methods used for creating and adding user in part of code in which before is used UserLocalServiceUtil.create(userId), are used methods for setting parameters like user.setScreenName(name) and then the user is added with UserLocalServiceUtil.add(user). What's the difference?
At last to modify the Login Portlet of Liferay I have to use hook?

Regards
thumbnail
Nicolas Tamayo, modificado hace 11 años.

RE: Development of login portlet

Junior Member Mensajes: 29 Fecha de incorporación: 3/10/12 Mensajes recientes
Hi Matt.

as my knownloedge covers about hooks, the hook only allows the customization over the:
  • JPSs
  • Services
  • Portal Properties
  • and Portal Language

whereby a hook not will be a good option to modify the functionlity that you want modifiy. so your option of customization for the Liferay Login Portlet, is the Ext Plugin.

in the case that you can't use the Hook Plugin, and the Ext plugin not will be the option that you prefer. Then the Custom Portlet is the Solution.

if you want use the Custom Portlet you have many options. all the options that you presented, are possible to add a user to the Liferay Database.

in my case, i use the UserServiceUtil.addUserWithWorkflow(.......);, this method is the used for the Liferay Login Portlet in the User Creation Process.

after making all the process to the User Registration. the Authentication Process is done for the LoginUtil.login(.....);, this method is called through PortalClassInvoker.

Regards.
thumbnail
Jan Geißler, modificado hace 11 años.

RE: Development of login portlet

Liferay Master Mensajes: 735 Fecha de incorporación: 5/07/11 Mensajes recientes
Correct me if I am wrong, but what I have understood so far is this one requirement:
There is an Organization where he wants to add the User Programatically after a new User has created his account.

So in my mind the easiest way to implement it would be a ModelListener where you only would have to overwrite:
onAfterCreate(User user)
and implement addUserToOrganization.... this is a 2 Liner... No need for ext or a custom LoginPortlet, as this would end up in 100 times more work.
Just my 2 cent.
Matt S., modificado hace 11 años.

RE: Development of login portlet

Junior Member Mensajes: 36 Fecha de incorporación: 29/11/12 Mensajes recientes
I'm sorry for late reply, I tried with ModelListener as you said me but I have an error in the liferay-hook.xml file, in particular when I put this code

<hook>
<portal-properties>portal.properties</portal-properties>
</hook>


the error is

Caused by: org.dom4j.DocumentException: Error on line 7 of document  : The content of element type "hook" must match "(portal-properties?,language-properties*,custom-jsp-dir?,custom-jsp-global?,indexer-post-processor*,service*,servlet-filter*,servlet-filter-mapping*,struts-action*)". Nested exception: The content of element type "hook" must match "(portal-properties?,language-properties*,custom-jsp-dir?,custom-jsp-global?,indexer-post-processor*,service*,servlet-filter*,servlet-filter-mapping*,struts-action*)".
	at org.dom4j.io.SAXReader.read(SAXReader.java:482)
	at org.dom4j.io.SAXReader.read(SAXReader.java:365)
	at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:396)
	... 28 more


In the portal properties file i wrote value.object.listener.com.liferay.portal.model.User=hook.AddUserListener , where AddUserListener is my class which extends BaseModelListener and it is in docroot/WEB-INF/src/hook directory. Where i'm wrong?