Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Daniel Wilmes
reset password
April 3, 2013 9:51 AM
Answer

Daniel Wilmes

Rank: Regular Member

Posts: 164

Join Date: May 23, 2011

Recent Posts

Hello,

I am using
liferay 6.1.1 ga2
mysql 5.6

I have created a hook within a portlet project, which seems to work fine. Inside of the hook I do an upgrade process to delete all the liferay default "stuff" (organizations, users, etc)

After I have deleted the liferay stuff I generate a user, which works fine, but I want the user not to have to reset the their password after they login for the first time...

Here is the user code:

 1
 2
 3        User user = UserLocalServiceUtil.addUser(
 4                creatorUserId, companyId, autoPassword, password1, password2,
 5                autoScreenName, screenName, emailAddress, facebookId, openId,
 6                locale, firstName, middleName, lastName, prefixId, suffixId, male,
 7                birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds,
 8                organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);
 9
10        Date data = new Date();
11        user.setAgreedToTermsOfUse(true);
12        user.setEmailAddressVerified(true);
13        user.setPasswordReset(false);
14        user.setPasswordModified(true);
15        user.setPasswordModifiedDate(date);
16        user.setStatus(WorkflowConstants.STATUS_APPROVED);
17        UserLocalServiceUtil.updateUser(user);


Does anyone know how to not make a user have to change their password on first login?

Thanks,
Daniel
Pradeep Sharma
RE: reset password
April 3, 2013 12:35 PM
Answer

Pradeep Sharma

Rank: Junior Member

Posts: 47

Join Date: September 6, 2011

Recent Posts

Hi Daniel,

The simplest way what I know how to disable the reset password is just uncheck the reset password check box. Hope for that we do not need any programming. Just Control panel does those thing.

Hope this Image will clear your doubts and will help.
Thank You !
Pradeep
Attachment

Attachments: Liferay Password Change Page.png (74.9k)
Daniel Wilmes
RE: reset password
April 19, 2013 10:53 AM
Answer

Daniel Wilmes

Rank: Regular Member

Posts: 164

Join Date: May 23, 2011

Recent Posts

I made a hook for the add user method that seemed to work:

Liferay-hook.xml
<service>
<service-type>com.liferay.portal.service.UserLocalService</service-type>
<service-impl>com.service.hook.CustomUserLocalServiceImpl </service-impl>
</service>

 1
 2/*
 3 * To change this template, choose Tools | Templates
 4 * and open the template in the editor.
 5 */
 6package com.service.hook;
 7
 8import com.liferay.portal.kernel.exception.PortalException;
 9import com.liferay.portal.kernel.exception.SystemException;
10import com.liferay.portal.kernel.log.Log;
11import com.liferay.portal.kernel.log.LogFactoryUtil;
12import com.liferay.portal.model.User;
13import com.liferay.portal.service.UserLocalService;
14import com.liferay.portal.service.UserLocalServiceUtil;
15import com.liferay.portal.service.UserLocalServiceWrapper;
16
17
18public class CustomUserLocalServiceImpl extends UserLocalServiceWrapper {
19
20    private static Log _log = LogFactoryUtil.getLog(ServupUserLocalServiceImpl.class);
21
22    public ServupUserLocalServiceImpl(UserLocalService userLocalService) {
23        super(userLocalService);
24    }
25
26    @Override
27    public User addUser(long creatorUserId,
28            long companyId, boolean autoPassword, java.lang.String password1,
29            java.lang.String password2, boolean autoScreenName,
30            java.lang.String screenName, java.lang.String emailAddress,
31            long facebookId, java.lang.String openId, java.util.Locale locale,
32            java.lang.String firstName, java.lang.String middleName,
33            java.lang.String lastName, int prefixId, int suffixId, boolean male,
34            int birthdayMonth, int birthdayDay, int birthdayYear,
35            java.lang.String jobTitle, long[] groupIds, long[] organizationIds,
36            long[] roleIds, long[] userGroupIds, boolean sendEmail,
37            com.liferay.portal.service.ServiceContext serviceContext)
38            throws PortalException, SystemException {
39        User user = super.addUser(creatorUserId, companyId,
40                autoPassword, password1, password2, autoScreenName, screenName,
41                emailAddress, facebookId, openId, locale, firstName, middleName,
42                lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay,
43                birthdayYear, jobTitle, groupIds, organizationIds, roleIds,
44                userGroupIds, false, serviceContext);
45        user.setPasswordReset(false);
46        UserLocalServiceUtil.updateUser(user);
47        return user;
48    }
49}