Skip to content
This repository has been archived by the owner on Oct 10, 2020. It is now read-only.

handleLogin Issue #1

Open
GudeAparna opened this issue Jan 8, 2018 · 7 comments
Open

handleLogin Issue #1

GudeAparna opened this issue Jan 8, 2018 · 7 comments

Comments

@GudeAparna
Copy link

We tried react-ms-login plugin,after successful login we redirect to redirect uri page.But we are not getting data into handleLogin function.

@nitheeshskiploop
Copy link

same here. also in pop up complete html is loading instead of same tab

@San10694
Copy link

San10694 commented Apr 2, 2018

@GudeAparna and @nitheeshskiploop did u guys find any solution?
for me, "handleLogin" function is not working and I don't want to open other tabs after successfully logged in.

@nitheeshskiploop
Copy link

nitheeshskiploop commented Apr 2, 2018

@San10694 i have written authcomplete() function redirect page.

`
function authComplete() {
function getFragment() {
if (window.location.hash.indexOf("#") === 0) {
return parseQueryString(window.location.hash.substr(1));
} else {
return {};
}
};

  function parseQueryString(queryString) {
    var data = {},
      pairs,
      pair,
      separatorIndex,
      escapedKey,
      escapedValue,
      key,
      value;

    if (queryString === null) {
      return data;
    }

    pairs = queryString.split("&");

    for (var i = 0; i < pairs.length; i++) {
      pair = pairs[i];
      separatorIndex = pair.indexOf("=");

      if (separatorIndex === -1) {
        escapedKey = pair;
        escapedValue = null;
      } else {
        escapedKey = pair.substr(0, separatorIndex);
        escapedValue = pair.substr(separatorIndex + 1);
      }

      key = decodeURIComponent(escapedKey);
      value = decodeURIComponent(escapedValue);

      data[key] = value;
    }

    return data;
  }

  var fragment = getFragment();

  window.location.hash = fragment.state || '/login';

  if (window.opener) {
    window.opener.authScope.authCompletedCB(fragment);

    window.close();
  }
}

`

this will work

@San10694
Copy link

San10694 commented Apr 2, 2018

@nitheeshskiploop thank you, bro, for your valuable response, but when to call that authComplete() function. I am not getting any data into handleLogin function. Can you help me with this ?

@nishch
Copy link
Owner

nishch commented Apr 2, 2018

@San10694 @nitheeshskiploop I believe you might be missing the final step mentioned in the document, i.e. redirectPage needs to have a reference to https://github.com/nishant-chaturvedi/react-ms-login/blob/master/dist/authComplete.js

@San10694
Copy link

San10694 commented Apr 4, 2018

@nishant-chaturvedi can you please tell me where to put authComplete.js inside my project.I am using "react": "16.0.0",. I am confused where to call authComplete.js

@nitheeshskiploop
Copy link

i put in login page authComplete Function and redirect page is login irself. otherwise you can create separate route and put it in redirect url, only auth complete should be there in separate route.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants