Search in sources :

Example 21 with User

use of com.liferay.portal.model.User in project liferay-ide by liferay.

the class UserLocalServiceImpl method checkLoginFailureByScreenName.

/**
 * Adds a failed login attempt to the user with the screen name and updates
 * the user's last failed login date.
 *
 * @param  companyId the primary key of the user's company
 * @param  screenName the user's screen name
 * @throws PortalException if a user with the screen name could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public void checkLoginFailureByScreenName(long companyId, String screenName) throws PortalException, SystemException {
    User user = getUserByScreenName(companyId, screenName);
    checkLoginFailure(user);
}
Also used : User(com.liferay.portal.model.User)

Example 22 with User

use of com.liferay.portal.model.User 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 23 with User

use of com.liferay.portal.model.User in project liferay-ide by liferay.

the class UserLocalServiceImpl method sendEmailAddressVerification.

/**
 * Sends an email address verification to the user.
 *
 * @param  user the verification email recipient
 * @param  emailAddress the recipient's email address
 * @param  serviceContext the service context to be applied. Must set the
 *         portal URL, main path, primary key of the layout, remote address,
 *         remote host, and agent for the user.
 * @throws PortalException if a portal exception occurred
 * @throws SystemException if a system exception occurred
 */
@Override
public void sendEmailAddressVerification(User user, String emailAddress, ServiceContext serviceContext) throws PortalException, SystemException {
    if (user.isEmailAddressVerified() && StringUtil.equalsIgnoreCase(emailAddress, user.getEmailAddress())) {
        return;
    }
    Ticket ticket = ticketLocalService.addTicket(user.getCompanyId(), User.class.getName(), user.getUserId(), TicketConstants.TYPE_EMAIL_ADDRESS, emailAddress, null, serviceContext);
    String verifyEmailAddressURL = serviceContext.getPortalURL() + serviceContext.getPathMain() + "/portal/verify_email_address?ticketKey=" + ticket.getKey();
    long plid = serviceContext.getPlid();
    if (plid > 0) {
        Layout layout = layoutLocalService.fetchLayout(plid);
        if (layout != null) {
            Group group = layout.getGroup();
            if (!layout.isPrivateLayout() && !group.isUser()) {
                verifyEmailAddressURL += "&p_l_id=" + serviceContext.getPlid();
            }
        }
    }
    String fromName = PrefsPropsUtil.getString(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME);
    String fromAddress = PrefsPropsUtil.getString(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
    String toName = user.getFullName();
    String toAddress = emailAddress;
    String subject = PrefsPropsUtil.getContent(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_VERIFICATION_SUBJECT);
    String body = PrefsPropsUtil.getContent(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_VERIFICATION_BODY);
    SubscriptionSender subscriptionSender = new SubscriptionSender();
    subscriptionSender.setBody(body);
    subscriptionSender.setCompanyId(user.getCompanyId());
    subscriptionSender.setContextAttributes("[$EMAIL_VERIFICATION_CODE$]", ticket.getKey(), "[$EMAIL_VERIFICATION_URL$]", verifyEmailAddressURL, "[$REMOTE_ADDRESS$]", serviceContext.getRemoteAddr(), "[$REMOTE_HOST$]", serviceContext.getRemoteHost(), "[$USER_ID$]", user.getUserId(), "[$USER_SCREENNAME$]", user.getScreenName());
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setMailId("user", user.getUserId(), System.currentTimeMillis(), PwdGenerator.getPassword());
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setSubject(subject);
    subscriptionSender.setUserId(user.getUserId());
    subscriptionSender.addRuntimeSubscribers(toAddress, toName);
    subscriptionSender.flushNotificationsAsync();
}
Also used : Ticket(com.liferay.portal.model.Ticket) Group(com.liferay.portal.model.Group) UserGroup(com.liferay.portal.model.UserGroup) User(com.liferay.portal.model.User) Layout(com.liferay.portal.model.Layout) SubscriptionSender(com.liferay.portal.util.SubscriptionSender)

Example 24 with User

use of com.liferay.portal.model.User in project liferay-ide by liferay.

the class UserLocalServiceImpl method updateAgreedToTermsOfUse.

/**
 * Updates whether the user has agreed to the terms of use.
 *
 * @param  userId the primary key of the user
 * @param  agreedToTermsOfUse whether the user has agreet to the terms of
 *         use
 * @return the user
 * @throws PortalException if a user with the primary key could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public User updateAgreedToTermsOfUse(long userId, boolean agreedToTermsOfUse) throws PortalException, SystemException {
    User user = userPersistence.findByPrimaryKey(userId);
    user.setAgreedToTermsOfUse(agreedToTermsOfUse);
    userPersistence.update(user);
    return user;
}
Also used : User(com.liferay.portal.model.User)

Example 25 with User

use of com.liferay.portal.model.User in project liferay-ide by liferay.

the class UserLocalServiceImpl method getUserByUuidAndCompanyId.

/**
 * Returns the user with the UUID.
 *
 * @param  uuid the user's UUID
 * @param  companyId the primary key of the user's company
 * @return the user with the UUID
 * @throws PortalException if a user with the UUID could not be found
 * @throws SystemException if a system exception occurred
 */
@Override
public User getUserByUuidAndCompanyId(String uuid, long companyId) throws PortalException, SystemException {
    List<User> users = userPersistence.findByUuid_C(uuid, companyId);
    if (users.isEmpty()) {
        StringBundler sb = new StringBundler(5);
        sb.append("{uuid=");
        sb.append(uuid);
        sb.append(", companyId=");
        sb.append(companyId);
        sb.append("}");
        throw new NoSuchUserException(sb.toString());
    } else {
        return users.get(0);
    }
}
Also used : User(com.liferay.portal.model.User) NoSuchUserException(com.liferay.portal.NoSuchUserException) StringBundler(com.liferay.portal.kernel.util.StringBundler)

Aggregations

User (com.liferay.portal.model.User)97 Date (java.util.Date)22 SystemException (com.liferay.portal.kernel.exception.SystemException)17 Group (com.liferay.portal.model.Group)15 PortalException (com.liferay.portal.kernel.exception.PortalException)13 Company (com.liferay.portal.model.Company)11 ServiceContext (com.liferay.portal.service.ServiceContext)11 Indexable (com.liferay.portal.kernel.search.Indexable)10 UserGroup (com.liferay.portal.model.UserGroup)10 IOException (java.io.IOException)9 DuplicateUserEmailAddressException (com.liferay.portal.DuplicateUserEmailAddressException)8 EncryptorException (com.liferay.util.EncryptorException)7 Song (org.liferay.jukebox.model.Song)7 Contact (com.liferay.portal.model.Contact)6 PrincipalException (com.liferay.portal.security.auth.PrincipalException)6 Album (org.liferay.jukebox.model.Album)6 DuplicateUserScreenNameException (com.liferay.portal.DuplicateUserScreenNameException)5 GroupFriendlyURLException (com.liferay.portal.GroupFriendlyURLException)5 NoSuchImageException (com.liferay.portal.NoSuchImageException)5 NoSuchOrganizationException (com.liferay.portal.NoSuchOrganizationException)5