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);
}
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();
}
}
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();
}
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;
}
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);
}
}
Aggregations