Search in sources :

Example 1 with DuplicateUserEmailAddressException

use of com.liferay.portal.DuplicateUserEmailAddressException in project liferay-ide by liferay.

the class UserLocalServiceImpl method validate.

protected void validate(long userId, String screenName, String emailAddress, String openId, String firstName, String middleName, String lastName, String smsSn) throws PortalException, SystemException {
    User user = userPersistence.findByPrimaryKey(userId);
    if (!StringUtil.equalsIgnoreCase(user.getScreenName(), screenName)) {
        validateScreenName(user.getCompanyId(), userId, screenName);
    }
    validateEmailAddress(user.getCompanyId(), emailAddress);
    validateOpenId(user.getCompanyId(), userId, openId);
    if (!user.isDefaultUser()) {
        if (Validator.isNotNull(emailAddress) && !StringUtil.equalsIgnoreCase(user.getEmailAddress(), emailAddress)) {
            if (userPersistence.fetchByC_EA(user.getCompanyId(), emailAddress) != null) {
                throw new DuplicateUserEmailAddressException("{userId=" + userId + "}");
            }
        }
        validateFullName(user.getCompanyId(), firstName, middleName, lastName);
    }
    if (Validator.isNotNull(smsSn) && !Validator.isEmailAddress(smsSn)) {
        throw new UserSmsException();
    }
}
Also used : UserSmsException(com.liferay.portal.UserSmsException) User(com.liferay.portal.model.User) DuplicateUserEmailAddressException(com.liferay.portal.DuplicateUserEmailAddressException)

Example 2 with DuplicateUserEmailAddressException

use of com.liferay.portal.DuplicateUserEmailAddressException in project liferay-ide by liferay.

the class UserLocalServiceImpl method validate.

protected void validate(long companyId, long userId, boolean autoPassword, String password1, String password2, boolean autoScreenName, String screenName, String emailAddress, String openId, String firstName, String middleName, String lastName, long[] organizationIds) throws PortalException, SystemException {
    validateCompanyMaxUsers(companyId);
    if (!autoScreenName) {
        validateScreenName(companyId, userId, screenName);
    }
    if (!autoPassword) {
        PasswordPolicy passwordPolicy = passwordPolicyLocalService.getDefaultPasswordPolicy(companyId);
        PwdToolkitUtil.validate(companyId, 0, password1, password2, passwordPolicy);
    }
    validateEmailAddress(companyId, emailAddress);
    if (Validator.isNotNull(emailAddress)) {
        User user = userPersistence.fetchByC_EA(companyId, emailAddress);
        if ((user != null) && (user.getUserId() != userId)) {
            throw new DuplicateUserEmailAddressException("{userId=" + userId + "}");
        }
    }
    validateOpenId(companyId, userId, openId);
    validateFullName(companyId, firstName, middleName, lastName);
    if (organizationIds != null) {
        for (long organizationId : organizationIds) {
            Organization organization = organizationPersistence.fetchByPrimaryKey(organizationId);
            if (organization == null) {
                throw new NoSuchOrganizationException("{organizationId=" + organizationId + "}");
            }
        }
    }
}
Also used : User(com.liferay.portal.model.User) Organization(com.liferay.portal.model.Organization) DuplicateUserEmailAddressException(com.liferay.portal.DuplicateUserEmailAddressException) PasswordPolicy(com.liferay.portal.model.PasswordPolicy) NoSuchOrganizationException(com.liferay.portal.NoSuchOrganizationException)

Example 3 with DuplicateUserEmailAddressException

use of com.liferay.portal.DuplicateUserEmailAddressException in project liferay-ide by liferay.

the class UserLocalServiceImpl method verifyEmailAddress.

/**
 * Verifies the email address of the ticket.
 *
 * @param  ticketKey the ticket key
 * @throws PortalException if a ticket matching the ticket key could not be
 *         found, if the ticket has expired, if the ticket is an email
 *         address ticket, or if the email address is invalid
 * @throws SystemException if a system exception occurred
 */
@Override
public void verifyEmailAddress(String ticketKey) throws PortalException, SystemException {
    Ticket ticket = ticketLocalService.getTicket(ticketKey);
    if (ticket.isExpired() || (ticket.getType() != TicketConstants.TYPE_EMAIL_ADDRESS)) {
        throw new NoSuchTicketException("{ticketKey=" + ticketKey + "}");
    }
    User user = userPersistence.findByPrimaryKey(ticket.getClassPK());
    String emailAddress = ticket.getExtraInfo();
    emailAddress = StringUtil.toLowerCase(emailAddress).trim();
    if (!emailAddress.equals(user.getEmailAddress())) {
        if (userPersistence.fetchByC_EA(user.getCompanyId(), emailAddress) != null) {
            throw new DuplicateUserEmailAddressException("{userId=" + user.getUserId() + "}");
        }
        setEmailAddress(user, StringPool.BLANK, user.getFirstName(), user.getMiddleName(), user.getLastName(), emailAddress);
        Contact contact = user.getContact();
        contact.setEmailAddress(user.getEmailAddress());
        contactPersistence.update(contact);
    }
    user.setEmailAddressVerified(true);
    userPersistence.update(user);
    ticketLocalService.deleteTicket(ticket);
}
Also used : Ticket(com.liferay.portal.model.Ticket) NoSuchTicketException(com.liferay.portal.NoSuchTicketException) User(com.liferay.portal.model.User) DuplicateUserEmailAddressException(com.liferay.portal.DuplicateUserEmailAddressException) Contact(com.liferay.portal.model.Contact)

Aggregations

DuplicateUserEmailAddressException (com.liferay.portal.DuplicateUserEmailAddressException)3 User (com.liferay.portal.model.User)3 NoSuchOrganizationException (com.liferay.portal.NoSuchOrganizationException)1 NoSuchTicketException (com.liferay.portal.NoSuchTicketException)1 UserSmsException (com.liferay.portal.UserSmsException)1 Contact (com.liferay.portal.model.Contact)1 Organization (com.liferay.portal.model.Organization)1 PasswordPolicy (com.liferay.portal.model.PasswordPolicy)1 Ticket (com.liferay.portal.model.Ticket)1