Fórum

reset password

Daniel Wilmes, modificado 11 Anos atrás.

reset password

Regular Member Postagens: 164 Data de Entrada: 23/05/11 Postagens Recentes
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:


 
        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, serviceContext);

        Date data = new Date();
        user.setAgreedToTermsOfUse(true);
        user.setEmailAddressVerified(true);
        user.setPasswordReset(false);
        user.setPasswordModified(true);
        user.setPasswordModifiedDate(date);
        user.setStatus(WorkflowConstants.STATUS_APPROVED);
        UserLocalServiceUtil.updateUser(user);


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

Thanks,
Daniel
thumbnail
Pradeep Kumar Badhai, modificado 11 Anos atrás.

RE: reset password

Junior Member Postagens: 50 Data de Entrada: 06/09/11 Postagens Recentes
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
Daniel Wilmes, modificado 11 Anos atrás.

RE: reset password

Regular Member Postagens: 164 Data de Entrada: 23/05/11 Postagens Recentes
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>


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.service.hook;

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.model.User;
import com.liferay.portal.service.UserLocalService;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceWrapper;


public class CustomUserLocalServiceImpl extends UserLocalServiceWrapper {

    private static Log _log = LogFactoryUtil.getLog(ServupUserLocalServiceImpl.class);

    public ServupUserLocalServiceImpl(UserLocalService userLocalService) {
        super(userLocalService);
    }

    @Override
    public User addUser(long creatorUserId,
            long companyId, boolean autoPassword, java.lang.String password1,
            java.lang.String password2, boolean autoScreenName,
            java.lang.String screenName, java.lang.String emailAddress,
            long facebookId, java.lang.String openId, java.util.Locale locale,
            java.lang.String firstName, java.lang.String middleName,
            java.lang.String lastName, int prefixId, int suffixId, boolean male,
            int birthdayMonth, int birthdayDay, int birthdayYear,
            java.lang.String jobTitle, long[] groupIds, long[] organizationIds,
            long[] roleIds, long[] userGroupIds, boolean sendEmail,
            com.liferay.portal.service.ServiceContext serviceContext)
            throws PortalException, SystemException {
        User user = super.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, false, serviceContext);
        user.setPasswordReset(false);
        UserLocalServiceUtil.updateUser(user);
        return user;
    }
}