Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-60825

Not support Facebook Login for multiple virtual host

    Details

    • Fix Priority:
      3

      Description

      I've created a site, and I've setted a virtual host for public layoutset.

      Facebook login was setted before for the guest site.

      When I try to login using the virtual host, facebook login failed!

      Solution:

      login.jsp

      Unable to find source-code formatter for language: jsp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      String facebookAuthRedirectURL = FacebookConnectUtil.getRedirectURL(themeDisplay.getCompanyId());
      
      				if(Validator.isNotNull(themeDisplay.getLayoutSet().getVirtualHostname())) {
      					facebookAuthRedirectURL = "http://" + themeDisplay.getLayoutSet().getVirtualHostname() + "/c/login/facebook_connect_oauth";
      				}
      				facebookAuthRedirectURL = HttpUtil.addParameter(facebookAuthRedirectURL, "redirect", loginRedirectURL.toString());
      

      FacebookConnectAction.java

      String facebookConnectRedirectURL = request.getRequestURL().toString() + "?" + request.getQueryString(); 		
      		String token = FacebookConnectUtil.getAccessToken(themeDisplay.getCompanyId(), facebookConnectRedirectURL, code);
      

      FacebookConnectImpl.java

      	public String getAccessToken(long companyId, String redirect, String code)
      		throws SystemException {
      
      		
      		String url = FacebookConnectUtil.getAccessTokenURL(companyId);
      		url = HttpUtil.addParameter(url, "client_id", FacebookConnectUtil.getAppId(companyId));
      		url = HttpUtil.addParameter(url, "redirect_uri", FacebookConnectUtil.getRedirectURL(companyId));
      		url = HttpUtil.addParameter(url, "redirect_uri", redirect);
      		url = HttpUtil.addParameter(url, "client_secret", FacebookConnectUtil.getAppSecret(companyId));
      		url = HttpUtil.addParameter(url, "code", code);
      
      		Http.Options options = new Http.Options();
      
      		options.setLocation(url);
      		options.setPost(true);
      
      		try {
      			String content = HttpUtil.URLtoString(options);
      
      			if (Validator.isNotNull(content)) {
      				int x = content.indexOf("access_token=");
      
      				if (x >= 0) {
      					int y = content.indexOf(CharPool.AMPERSAND, x);
      
      					if (y < x) {
      						y = content.length();
      					}
      
      					return content.substring(x + 13, y);
      				}
      			}
      		}
      		catch (Exception e) {
      			throw new SystemException(
      				"Unable to retrieve Facebook access token", e);
      		}
      
      		return null;
      	}
      

      Facebook

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                10 weeks, 5 days ago

                Packages

                Version Package