List of usage examples for com.liferay.portal.kernel.util WebKeys FACEBOOK_USER_EMAIL_ADDRESS
String FACEBOOK_USER_EMAIL_ADDRESS
To view the source code for com.liferay.portal.kernel.util WebKeys FACEBOOK_USER_EMAIL_ADDRESS.
Click Source Link
From source file:com.liferay.login.authentication.facebook.connect.web.internal.portlet.action.FacebookConnectAction.java
License:Open Source License
protected User addUser(HttpSession session, long companyId, JSONObject jsonObject) throws Exception { long creatorUserId = 0; boolean autoPassword = true; String password1 = StringPool.BLANK; String password2 = StringPool.BLANK; boolean autoScreenName = true; String screenName = StringPool.BLANK; String emailAddress = jsonObject.getString("email"); long facebookId = jsonObject.getLong("id"); String openId = StringPool.BLANK; Locale locale = LocaleUtil.getDefault(); String firstName = jsonObject.getString("first_name"); String middleName = StringPool.BLANK; String lastName = jsonObject.getString("last_name"); long prefixId = 0; long suffixId = 0; boolean male = Objects.equals(jsonObject.getString("gender"), "male"); int birthdayMonth = Calendar.JANUARY; int birthdayDay = 1; int birthdayYear = 1970; String jobTitle = StringPool.BLANK; long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; long[] userGroupIds = null; boolean sendEmail = true; ServiceContext serviceContext = new ServiceContext(); User user = _userLocalService.addUser(creatorUserId, companyId, 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 = _userLocalService.updateLastLogin(user.getUserId(), user.getLoginIP()); user = _userLocalService.updatePasswordReset(user.getUserId(), false); user = _userLocalService.updateEmailAddressVerified(user.getUserId(), true); session.setAttribute(WebKeys.FACEBOOK_USER_EMAIL_ADDRESS, emailAddress); return user;//from w w w . j a v a 2s. c om }
From source file:com.liferay.login.authentication.facebook.connect.web.internal.portlet.action.FacebookConnectAction.java
License:Open Source License
protected User setFacebookCredentials(HttpSession session, long companyId, String token) throws Exception { JSONObject jsonObject = _facebookConnect.getGraphResources(companyId, "/me", token, "id,email,first_name,last_name,gender,verified"); if ((jsonObject == null) || (jsonObject.getJSONObject("error") != null)) { return null; }//from www . j a v a 2 s . c o m if (_facebookConnect.isVerifiedAccountRequired(companyId) && !jsonObject.getBoolean("verified")) { return null; } User user = null; long facebookId = jsonObject.getLong("id"); if (facebookId > 0) { session.setAttribute(FacebookConnectWebKeys.FACEBOOK_ACCESS_TOKEN, token); user = _userLocalService.fetchUserByFacebookId(companyId, facebookId); if ((user != null) && !user.isActive()) { return null; } else if ((user != null) && (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) { session.setAttribute(FacebookConnectWebKeys.FACEBOOK_USER_ID, String.valueOf(facebookId)); } } String emailAddress = jsonObject.getString("email"); if ((user == null) && Validator.isNotNull(emailAddress)) { user = _userLocalService.fetchUserByEmailAddress(companyId, emailAddress); if ((user != null) && !user.isActive()) { return null; } else if ((user != null) && (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) { session.setAttribute(WebKeys.FACEBOOK_USER_EMAIL_ADDRESS, emailAddress); } } if (user != null) { if (user.getStatus() == WorkflowConstants.STATUS_INCOMPLETE) { session.setAttribute(WebKeys.FACEBOOK_INCOMPLETE_USER_ID, facebookId); user.setEmailAddress(jsonObject.getString("email")); user.setFirstName(jsonObject.getString("first_name")); user.setLastName(jsonObject.getString("last_name")); return user; } user = updateUser(user, jsonObject); } else { user = addUser(session, companyId, jsonObject); } return user; }