List of usage examples for com.liferay.portal.util PropsValues LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD
boolean LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD
To view the source code for com.liferay.portal.util PropsValues LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD.
Click Source Link
From source file:com.liferay.login.web.internal.portlet.action.CreateAccountMVCActionCommand.java
License:Open Source License
protected void addUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = _portal.getHttpServletRequest(actionRequest); HttpSession session = request.getSession(); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); boolean autoPassword = true; String password1 = null;/*from ww w . j av a 2s. c o m*/ String password2 = null; boolean autoScreenName = isAutoScreenName(); String screenName = ParamUtil.getString(actionRequest, "screenName"); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); long facebookId = ParamUtil.getLong(actionRequest, "facebookId"); String openId = ParamUtil.getString(actionRequest, "openId"); String languageId = ParamUtil.getString(actionRequest, "languageId"); String firstName = ParamUtil.getString(actionRequest, "firstName"); String middleName = ParamUtil.getString(actionRequest, "middleName"); String lastName = ParamUtil.getString(actionRequest, "lastName"); long prefixId = ParamUtil.getInteger(actionRequest, "prefixId"); long suffixId = ParamUtil.getInteger(actionRequest, "suffixId"); boolean male = ParamUtil.getBoolean(actionRequest, "male", true); int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth"); int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay"); int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear"); String jobTitle = ParamUtil.getString(actionRequest, "jobTitle"); long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; long[] userGroupIds = null; boolean sendEmail = true; ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest); if (PropsValues.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD) { autoPassword = false; password1 = ParamUtil.getString(actionRequest, "password1"); password2 = ParamUtil.getString(actionRequest, "password2"); } boolean openIdPending = false; Boolean openIdLoginPending = (Boolean) session.getAttribute(WebKeys.OPEN_ID_LOGIN_PENDING); if ((openIdLoginPending != null) && openIdLoginPending.booleanValue() && Validator.isNotNull(openId)) { sendEmail = false; openIdPending = true; } User user = _userService.addUserWithWorkflow(company.getCompanyId(), autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, LocaleUtil.fromLanguageId(languageId), firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext); if (openIdPending) { session.setAttribute(WebKeys.OPEN_ID_LOGIN, Long.valueOf(user.getUserId())); session.removeAttribute(WebKeys.OPEN_ID_LOGIN_PENDING); } else { // Session messages if (user.getStatus() == WorkflowConstants.STATUS_APPROVED) { SessionMessages.add(request, "userAdded", user.getEmailAddress()); SessionMessages.add(request, "userAddedPassword", user.getPasswordUnencrypted()); } else { SessionMessages.add(request, "userPending", user.getEmailAddress()); } } // Send redirect sendRedirect(actionRequest, actionResponse, themeDisplay, user, user.getPasswordUnencrypted()); }
From source file:com.liferay.portlet.login.action.CreateAccountAction.java
License:Open Source License
protected void addUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); HttpSession session = request.getSession(); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); boolean autoPassword = true; String password1 = null;/*w w w . j a v a2s . c o m*/ String password2 = null; boolean autoScreenName = isAutoScreenName(); String screenName = ParamUtil.getString(actionRequest, "screenName"); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); long facebookId = ParamUtil.getLong(actionRequest, "facebookId"); String openId = ParamUtil.getString(actionRequest, "openId"); String firstName = ParamUtil.getString(actionRequest, "firstName"); String middleName = ParamUtil.getString(actionRequest, "middleName"); String lastName = ParamUtil.getString(actionRequest, "lastName"); int prefixId = ParamUtil.getInteger(actionRequest, "prefixId"); int suffixId = ParamUtil.getInteger(actionRequest, "suffixId"); boolean male = ParamUtil.getBoolean(actionRequest, "male", true); int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth"); int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay"); int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear"); String jobTitle = ParamUtil.getString(actionRequest, "jobTitle"); long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; long[] userGroupIds = null; boolean sendEmail = true; ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest); if (PropsValues.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD) { autoPassword = false; password1 = ParamUtil.getString(actionRequest, "password1"); password2 = ParamUtil.getString(actionRequest, "password2"); } boolean openIdPending = false; Boolean openIdLoginPending = (Boolean) session.getAttribute(WebKeys.OPEN_ID_LOGIN_PENDING); if ((openIdLoginPending != null) && (openIdLoginPending.booleanValue()) && (Validator.isNotNull(openId))) { sendEmail = false; openIdPending = true; } // check accountRole - numberPhone String accountRole = ParamUtil.getString(actionRequest, "accountRole", ""); String mobilePhone = ParamUtil.getString(actionRequest, "mobilePhone", ""); boolean subscriberAccount = false; if (accountRole.equals("subscriberAccount")) { subscriberAccount = true; if (!Validator.isPhoneNumber(mobilePhone)) { throw new Exception("mobile-phone-invalid"); } try { UserEntry tmpEmtry = UserEntryLocalServiceUtil.findByMobilePhone(mobilePhone); if (tmpEmtry != null) throw new Exception("mobile-phone-invalid"); } catch (Exception e) { // TODO: handle exception } } //accountRole User user = UserServiceUtil.addUserWithWorkflow(company.getCompanyId(), autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, themeDisplay.getLocale(), firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext); if (openIdPending) { session.setAttribute(WebKeys.OPEN_ID_LOGIN, new Long(user.getUserId())); session.removeAttribute(WebKeys.OPEN_ID_LOGIN_PENDING); } else { // Session messages if (user.getStatus() == WorkflowConstants.STATUS_APPROVED) { SessionMessages.add(request, "user_added", user.getEmailAddress()); SessionMessages.add(request, "user_added_password", user.getPasswordUnencrypted()); } else { SessionMessages.add(request, "user_pending", user.getEmailAddress()); } } // ============================================================ // create user success - ok then create vrbt_user // add new UserEntry ( vrbt_user table ) UserEntry userEntry = null; try { userEntry = UserEntryLocalServiceUtil .createUserEntry(CounterLocalServiceUtil.increment(UserEntry.class.getName())); userEntry.setUserId(user.getUserId()); userEntry.setUserName(user.getScreenName()); userEntry.setGroupId(user.getGroupId()); userEntry.setCompanyId(user.getCompanyId()); userEntry.setCreateDate(Calendar.getInstance().getTime()); userEntry.setStatus(1); if (subscriberAccount) { userEntry.setMobilePhone(mobilePhone); } UserEntryLocalServiceUtil.updateUserEntry(userEntry); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } // add role long roleId = 0; try { Role role = null; if (subscriberAccount) { role = RoleLocalServiceUtil.getRole(PortalUtil.getCompanyId(request), "Subscriber"); if (role != null) roleId = role.getRoleId(); } else { role = RoleLocalServiceUtil.getRole(PortalUtil.getCompanyId(request), "Third-party"); if (role != null) roleId = role.getRoleId(); } } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } System.out.println("roleId:" + roleId); if (roleId > 0) { try { RoleLocalServiceUtil.addUserRoles(user.getUserId(), new long[] { roleId }); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } // ============================================================ // Send redirect String login = null; if (company.getAuthType().equals(CompanyConstants.AUTH_TYPE_ID)) { login = String.valueOf(user.getUserId()); } else if (company.getAuthType().equals(CompanyConstants.AUTH_TYPE_SN)) { login = user.getScreenName(); } else { login = user.getEmailAddress(); } // fix login = user.getScreenName(); // sendRedirect(actionRequest, actionResponse, themeDisplay, login, user.getPasswordUnencrypted()); }
From source file:com.liferay.portlet.login.action.OldCreateAccountAction.java
License:Open Source License
protected void addUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest); HttpSession session = request.getSession(); ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); boolean autoPassword = true; String password1 = null;/* w w w .ja v a 2s .com*/ String password2 = null; boolean autoScreenName = isAutoScreenName(); String screenName = ParamUtil.getString(actionRequest, "screenName"); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); long facebookId = ParamUtil.getLong(actionRequest, "facebookId"); String openId = ParamUtil.getString(actionRequest, "openId"); String firstName = ParamUtil.getString(actionRequest, "firstName"); String middleName = ParamUtil.getString(actionRequest, "middleName"); String lastName = ParamUtil.getString(actionRequest, "lastName"); int prefixId = ParamUtil.getInteger(actionRequest, "prefixId"); int suffixId = ParamUtil.getInteger(actionRequest, "suffixId"); boolean male = ParamUtil.getBoolean(actionRequest, "male", true); int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth"); int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay"); int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear"); String jobTitle = ParamUtil.getString(actionRequest, "jobTitle"); long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; long[] userGroupIds = null; boolean sendEmail = true; ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest); if (PropsValues.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD) { autoPassword = false; password1 = ParamUtil.getString(actionRequest, "password1"); password2 = ParamUtil.getString(actionRequest, "password2"); } boolean openIdPending = false; Boolean openIdLoginPending = (Boolean) session.getAttribute(WebKeys.OPEN_ID_LOGIN_PENDING); if ((openIdLoginPending != null) && openIdLoginPending.booleanValue() && Validator.isNotNull(openId)) { sendEmail = false; openIdPending = true; } User user = UserServiceUtil.addUserWithWorkflow(company.getCompanyId(), autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, themeDisplay.getLocale(), firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext); if (openIdPending) { session.setAttribute(WebKeys.OPEN_ID_LOGIN, new Long(user.getUserId())); session.removeAttribute(WebKeys.OPEN_ID_LOGIN_PENDING); } else { // Session messages if (user.getStatus() == WorkflowConstants.STATUS_APPROVED) { SessionMessages.add(request, "user_added", user.getEmailAddress()); SessionMessages.add(request, "user_added_password", user.getPasswordUnencrypted()); } else { SessionMessages.add(request, "user_pending", user.getEmailAddress()); } } // Send redirect String login = null; if (company.getAuthType().equals(CompanyConstants.AUTH_TYPE_ID)) { login = String.valueOf(user.getUserId()); } else if (company.getAuthType().equals(CompanyConstants.AUTH_TYPE_SN)) { login = user.getScreenName(); } else { login = user.getEmailAddress(); } sendRedirect(actionRequest, actionResponse, themeDisplay, login, user.getPasswordUnencrypted()); }