Skip to content

Instantly share code, notes, and snippets.

@ShankarSumanth
Last active February 22, 2017 02:06
Show Gist options
  • Select an option

  • Save ShankarSumanth/bf61e0cc570637126e918a271e689419 to your computer and use it in GitHub Desktop.

Select an option

Save ShankarSumanth/bf61e0cc570637126e918a271e689419 to your computer and use it in GitHub Desktop.
kc.isLoggedIn = function () {
var promise = createPromise();
storage = new PersistentStorage();
if (!kc.responseMode) {
kc.responseMode = 'fragment';
}
if (!kc.responseType) {
kc.responseType = 'code';
kc.flow = 'standard';
}
var configPromise = loadConfig(config);
configPromise.success(function () {
checkIsLoggedIn(promise);
});
//promise.setSuccess(true);
return promise.promise;
}
kc.watchLogin = function () {
setTimeout(checkLogin, loginIframe.interval * 1000);
}
function checkIsLoggedIn(promise) {
setupCheckLoginIframe().success(function () {
checkLoginIframe().success(function (loggedIn) {
if (loggedIn) {
var callback = parseCallback(window.location.href);
if (!callback && !kc.token) {
adapter = loadAdapter();
kc.login({});
}
if (callback) {
processCallback(callback, promise);
}
if (kc.token)
setTimeout(checkLogin, loginIframe.interval * 1000);
}
}).error(function () {
storage.removeItem('oauth');
promise.setSuccess(false);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment