Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Michael Berezowski
Add new User as Guest
February 15, 2011 4:29 AM
Answer

Michael Berezowski

Rank: New Member

Posts: 13

Join Date: August 17, 2010

Recent Posts

Hello

I am using Liferay Portal Standard Edition 5.2.3 and my Goal is a Portlet so that guest are able to register themselves.
For this i used "add-user-portlet-5.2.3.1.war" from Robisoft with some minor changes.
The add User code looks like:
 1        ThemeDisplay themeDisplay = (ThemeDisplay)actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
 2         
 3         
 4        ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest);
 5       
 6        UserServiceUtil.addUser(
 7        themeDisplay.getCompanyId(), autoPassword, password1, password2,
 8        autoScreenName, screenName, emailAddress, facebookId, openId,
 9        LocaleUtil.getDefault(), firstName, middleName, lastName, prefixId,
10        suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle,
11        groupIds, organizationIds, roleIds, userGroupIds, sendEmail,
12        addresses, emailAddresses, phones, websites,
13        announcementsDeliveries, serviceContext);


Now the Problem: If i use this Portlet as an Admin everything works fine. As a guest the following Error occurs:
1[UserPermissionImpl:133] com.liferay.portal.NoSuchUserException: No User exists with the primary key 0
2com.liferay.portal.NoSuchUserException: No User exists with the primary key 0


So my Question is: Is there any other way to Add users, wich will work for guests?

Thanks for reading and even more for suggestion!
Arvind Mishra
RE: Add new User as Guest
February 15, 2011 7:15 PM
Answer

Arvind Mishra

Rank: Regular Member

Posts: 226

Join Date: February 13, 2008

Recent Posts

User table has defaultUser field. When you add a user using UserServiceUtil.addUser(), it sets defaultUser as false.

You need to set that field as true.
Michael Berezowski
RE: Add new User as Guest
February 21, 2011 1:18 AM
Answer

Michael Berezowski

Rank: New Member

Posts: 13

Join Date: August 17, 2010

Recent Posts

Thanks for your response!

I found another solution, just activate:
Control Panel --> Settings --> Authentication --> Allow strangers to create accounts?

and now the standard Login-Portlet has a "Create Account" possibility!
(Didn't see this before...emoticon)
Dhandapani S
RE: Add new User as Guest
February 21, 2011 2:23 AM
Answer

Dhandapani S

Rank: Regular Member

Posts: 170

Join Date: March 24, 2009

Recent Posts

Hi Michael,

Yes, You are correct, guest can add user by the control panel, or Create Account.

But the Add User portlet which is developed by Robisoft is for only admin purpose, thats why it was throwing error when u try to add user from guest. I hope u got the point.

Regards

Dhandapani S
Michael Berezowski
RE: Add new User as Guest
February 21, 2011 5:05 AM
Answer

Michael Berezowski

Rank: New Member

Posts: 13

Join Date: August 17, 2010

Recent Posts

Dear Dhandapani

I changed the Code of the Porltet and the Failure occured only by using the AddUser-function.
I have tried the AddUser-function in a Portlet that I have implemented for Guests, and the error occured too. So the Error is not related to the Portlet which is developed by Robisoft...