Example usage for com.liferay.portal.kernel.util PropsKeys LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD

List of usage examples for com.liferay.portal.kernel.util PropsKeys LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PropsKeys LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD.

Prototype

String LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD

To view the source code for com.liferay.portal.kernel.util PropsKeys LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD.

Click Source Link

Usage

From source file:com.abubusoft.liferay.linkedin.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();

    long creatorUserId = 0;
    long facebookId = ParamUtil.getLong(actionRequest, "facebookId");
    boolean autoPassword = true;
    boolean autoScreenName = false;
    boolean male = ParamUtil.getBoolean(actionRequest, "male", true);
    boolean sendEmail = true;
    String linkedinId = ParamUtil.getString(actionRequest, "linkedinId");
    String emailAddress = ParamUtil.getString(actionRequest, "emailAddress");
    String screenName = ParamUtil.getString(actionRequest, "screenName");
    String firstName = ParamUtil.getString(actionRequest, "firstName");
    String lastName = ParamUtil.getString(actionRequest, "lastName");
    String middleName = ParamUtil.getString(actionRequest, "middleName");
    String password1 = StringPool.BLANK;
    String password2 = StringPool.BLANK;
    String jobTitle = ParamUtil.getString(actionRequest, "jobTitle");
    String openId = StringPool.BLANK;
    int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth");
    int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay");
    int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear");
    int prefixId = ParamUtil.getInteger(actionRequest, "prefixId");
    int suffixId = ParamUtil.getInteger(actionRequest, "suffixId");
    Locale locale = themeDisplay.getLocale();

    long[] groupIds = null;
    long[] organizationIds = null;
    long[] roleIds = null;
    long[] userGroupIds = null;

    if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD))) {
        autoPassword = false;/*w ww  . j a va  2s  .c o m*/

        password1 = ParamUtil.getString(actionRequest, "password1");
        password2 = ParamUtil.getString(actionRequest, "password2");
    }

    ServiceContext serviceContext = new ServiceContext();

    User user = UserLocalServiceUtil.addUser(creatorUserId, company.getCompanyId(), 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);

    user = UserLocalServiceUtil.updateLastLogin(user.getUserId(), user.getLoginIP());

    user = UserLocalServiceUtil.updatePasswordReset(user.getUserId(), false);

    user = UserLocalServiceUtil.updateEmailAddressVerified(user.getUserId(), false);

    ExpandoValueLocalServiceUtil.addValue(company.getCompanyId(), User.class.getName(),
            ExpandoTableConstants.DEFAULT_TABLE_NAME, "linkedinId", user.getUserId(), linkedinId);

    session.setAttribute(LinkedinConstants.LINKEDIN_ID_LOGIN, new Long(user.getUserId()));

    session.removeAttribute(LinkedinConstants.LINKEDIN_LOGIN_PENDING);

    PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.FAST_LOGIN,
            themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

    portletURL.setWindowState(LiferayWindowState.POP_UP);
    portletURL.setParameter("struts_action", "/login/login_redirect");

    actionResponse.sendRedirect(portletURL.toString());
}

From source file:com.abubusoft.liferay.twitter.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();

    long creatorUserId = 0;
    long facebookId = ParamUtil.getLong(actionRequest, "facebookId");
    boolean autoPassword = true;
    boolean autoScreenName = false;
    boolean male = ParamUtil.getBoolean(actionRequest, "male", true);
    boolean sendEmail = true;
    String twitterId = ParamUtil.getString(actionRequest, "twitterId");
    String emailAddress = ParamUtil.getString(actionRequest, "emailAddress");
    String screenName = ParamUtil.getString(actionRequest, "screenName");
    String firstName = ParamUtil.getString(actionRequest, "firstName");
    String lastName = ParamUtil.getString(actionRequest, "lastName");
    String middleName = ParamUtil.getString(actionRequest, "middleName");
    String password1 = StringPool.BLANK;
    String password2 = StringPool.BLANK;
    String jobTitle = ParamUtil.getString(actionRequest, "jobTitle");
    String openId = StringPool.BLANK;
    int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth");
    int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay");
    int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear");
    int prefixId = ParamUtil.getInteger(actionRequest, "prefixId");
    int suffixId = ParamUtil.getInteger(actionRequest, "suffixId");
    Locale locale = themeDisplay.getLocale();

    long[] groupIds = null;
    long[] organizationIds = null;
    long[] roleIds = null;
    long[] userGroupIds = null;

    if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD))) {
        autoPassword = false;/*from   w  w w  . ja v a  2s  . co m*/

        password1 = ParamUtil.getString(actionRequest, "password1");
        password2 = ParamUtil.getString(actionRequest, "password2");
    }

    ServiceContext serviceContext = new ServiceContext();

    User user = UserLocalServiceUtil.addUser(creatorUserId, company.getCompanyId(), 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);

    user = UserLocalServiceUtil.updateLastLogin(user.getUserId(), user.getLoginIP());

    user = UserLocalServiceUtil.updatePasswordReset(user.getUserId(), false);

    user = UserLocalServiceUtil.updateEmailAddressVerified(user.getUserId(), false);

    ExpandoValueLocalServiceUtil.addValue(company.getCompanyId(), User.class.getName(),
            ExpandoTableConstants.DEFAULT_TABLE_NAME, TwitterConstants.TWITTER_ID_COLUMN_NAME, user.getUserId(),
            twitterId);

    session.setAttribute(TwitterConstants.TWITTER_ID_LOGIN, new Long(user.getUserId()));

    session.removeAttribute(TwitterConstants.TWITTER_LOGIN_PENDING);

    PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.FAST_LOGIN,
            themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

    portletURL.setWindowState(LiferayWindowState.POP_UP);
    portletURL.setParameter("struts_action", "/login/login_redirect");

    actionResponse.sendRedirect(portletURL.toString());
}

From source file:com.liferay.twitter.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();

    long creatorUserId = 0;
    long facebookId = ParamUtil.getLong(actionRequest, "facebookId");
    boolean autoPassword = true;
    boolean autoScreenName = false;
    boolean male = ParamUtil.getBoolean(actionRequest, "male", true);
    boolean sendEmail = true;
    String twitterId = ParamUtil.getString(actionRequest, "twitterId");
    String emailAddress = ParamUtil.getString(actionRequest, "emailAddress");
    String screenName = ParamUtil.getString(actionRequest, "screenName");
    String firstName = ParamUtil.getString(actionRequest, "firstName");
    String lastName = ParamUtil.getString(actionRequest, "lastName");
    String middleName = ParamUtil.getString(actionRequest, "middleName");
    String password1 = StringPool.BLANK;
    String password2 = StringPool.BLANK;
    String jobTitle = ParamUtil.getString(actionRequest, "jobTitle");
    String openId = StringPool.BLANK;
    int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth");
    int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay");
    int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear");
    int prefixId = ParamUtil.getInteger(actionRequest, "prefixId");
    int suffixId = ParamUtil.getInteger(actionRequest, "suffixId");
    Locale locale = themeDisplay.getLocale();

    long[] groupIds = null;
    long[] organizationIds = null;
    long[] roleIds = null;
    long[] userGroupIds = null;

    if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD))) {
        autoPassword = false;/*from w w w.  ja  va  2s  . c o m*/

        password1 = ParamUtil.getString(actionRequest, "password1");
        password2 = ParamUtil.getString(actionRequest, "password2");
    }

    ServiceContext serviceContext = new ServiceContext();

    User user = UserLocalServiceUtil.addUser(creatorUserId, company.getCompanyId(), 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);

    user = UserLocalServiceUtil.updateLastLogin(user.getUserId(), user.getLoginIP());

    user = UserLocalServiceUtil.updatePasswordReset(user.getUserId(), false);

    user = UserLocalServiceUtil.updateEmailAddressVerified(user.getUserId(), false);

    ExpandoValueLocalServiceUtil.addValue(company.getCompanyId(), User.class.getName(),
            ExpandoTableConstants.DEFAULT_TABLE_NAME, "twitterId", user.getUserId(), twitterId);

    session.setAttribute(TwitterConstants.TWITTER_ID_LOGIN, new Long(user.getUserId()));

    session.removeAttribute(TwitterConstants.TWITTER_LOGIN_PENDING);

    PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.FAST_LOGIN,
            themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

    portletURL.setWindowState(LiferayWindowState.POP_UP);
    portletURL.setParameter("struts_action", "/login/login_redirect");

    actionResponse.sendRedirect(portletURL.toString());
}

From source file:com.sympo.login.action.CreateAccountAction.java

License:Open Source License

protected void addTwitterUser(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;//from   w  w w . jav  a 2 s.  c o  m
    String password2 = null;
    boolean autoScreenName = false;
    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 = false;

    String twitterId = ParamUtil.getString(actionRequest, "twitterId");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest);

    if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD))) {

        autoPassword = false;

        password1 = ParamUtil.getString(actionRequest, "password1");
        password2 = ParamUtil.getString(actionRequest, "password2");
    }

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

    UserLocalServiceUtil.updateLastLogin(user.getUserId(), user.getLoginIP());

    UserLocalServiceUtil.updatePasswordReset(user.getUserId(), false);

    ExpandoValueLocalServiceUtil.addValue(company.getCompanyId(), User.class.getName(),
            ExpandoTableConstants.DEFAULT_TABLE_NAME, "twitterId", user.getUserId(), twitterId);

    session.setAttribute(TwitterConstants.TWITTER_ID_LOGIN, new Long(user.getUserId()));

    session.removeAttribute(TwitterConstants.TWITTER_LOGIN_PENDING);

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

    String redirect = PortalUtil.getPortalURL(request);

    actionResponse.sendRedirect(redirect);
}