diff --git a/samples/Parcel/src/code-flow-identityserver/sample-callback.js b/samples/Parcel/src/code-flow-identityserver/sample-callback.js
index c7cc23b37..132b05c6f 100644
--- a/samples/Parcel/src/code-flow-identityserver/sample-callback.js
+++ b/samples/Parcel/src/code-flow-identityserver/sample-callback.js
@@ -1,23 +1,12 @@
import { Log, UserManager, settings } from "./sample-settings";
+import { log } from "./sample";
Log.logger = console;
Log.level = Log.DEBUG;
-function log() {
- document.getElementById("out").innerText = "";
-
- Array.prototype.forEach.call(arguments, function(msg) {
- if (msg instanceof Error) {
- msg = "Error: " + msg.message;
- }
- else if (typeof msg !== "string") {
- msg = JSON.stringify(msg, null, 2);
- }
- document.getElementById("out").innerHTML += msg + "\r\n";
- });
-}
new UserManager(settings).signinCallback().then(function(user) {
log("signin response success", user);
}).catch(function(err) {
+ console.error(err);
log(err);
});
diff --git a/samples/Parcel/src/code-flow-identityserver/sample-popup-signin.js b/samples/Parcel/src/code-flow-identityserver/sample-popup-signin.js
index b3224fb51..9b0542c00 100644
--- a/samples/Parcel/src/code-flow-identityserver/sample-popup-signin.js
+++ b/samples/Parcel/src/code-flow-identityserver/sample-popup-signin.js
@@ -1,17 +1,12 @@
import { Log, UserManager, settings } from "./sample-settings";
-
-var log = {
- debug:logMessage, warn: logMessage, info: logMessage, error:logMessage
-};
-
-function logMessage(msg) {
- document.getElementById("logMessages").innerHTML += "
" + msg + "";
- console.log(msg);
-}
+import { log } from "./sample";
Log.logger = console; // log;
Log.level = Log.DEBUG;
-new UserManager(settings).signinCallback().catch(function(err) {
- Log.logger.error("error: " + err && err.message);
+new UserManager(settings).signinCallback().then(function(user) {
+ log("signin response success", user);
+}).catch(function(err) {
+ console.error(err);
+ log(err);
});
diff --git a/samples/Parcel/src/code-flow-identityserver/sample-popup-signout.js b/samples/Parcel/src/code-flow-identityserver/sample-popup-signout.js
index 4dd6fda7d..cf52f16c8 100644
--- a/samples/Parcel/src/code-flow-identityserver/sample-popup-signout.js
+++ b/samples/Parcel/src/code-flow-identityserver/sample-popup-signout.js
@@ -1,20 +1,13 @@
import { Log, UserManager, settings } from "./sample-settings";
+import { log } from "./sample";
Log.logger = console;
Log.level = Log.INFO;
-function log() {
- document.getElementById("out").innerText = "";
-
- Array.prototype.forEach.call(arguments, function(msg) {
- if (msg instanceof Error) {
- msg = "Error: " + msg.message;
- }
- else if (typeof msg !== "string") {
- msg = JSON.stringify(msg, null, 2);
- }
- document.getElementById("out").innerHTML += msg + "\r\n";
- });
-}
// can pass true param and will keep popup window open
-new UserManager(settings).signoutCallback();
+new UserManager(settings).signoutCallback().then(function() {
+ log("signout callback response success");
+}).catch(function(err) {
+ console.error(err);
+ log(err);
+});
diff --git a/samples/Parcel/src/code-flow-identityserver/sample-silent.js b/samples/Parcel/src/code-flow-identityserver/sample-silent.js
index df6157da5..23bc2c814 100644
--- a/samples/Parcel/src/code-flow-identityserver/sample-silent.js
+++ b/samples/Parcel/src/code-flow-identityserver/sample-silent.js
@@ -1,19 +1,12 @@
import { Log, UserManager, settings } from "./sample-settings";
+import { log } from "./sample";
Log.logger = console;
Log.level = Log.INFO;
-function log() {
- document.getElementById("out").innerText = "";
-
- Array.prototype.forEach.call(arguments, function(msg) {
- if (msg instanceof Error) {
- msg = "Error: " + msg.message;
- }
- else if (typeof msg !== "string") {
- msg = JSON.stringify(msg, null, 2);
- }
- document.getElementById("out").innerHTML += msg + "\r\n";
- });
-}
-void new UserManager(settings).signinCallback();
+new UserManager(settings).signinCallback().then(function(user) {
+ log("signin callback response success", user);
+}).catch(function(err) {
+ console.error(err);
+ log(err);
+});
diff --git a/samples/Parcel/src/code-flow-identityserver/sample.js b/samples/Parcel/src/code-flow-identityserver/sample.js
index b02891e83..6c9837f3c 100644
--- a/samples/Parcel/src/code-flow-identityserver/sample.js
+++ b/samples/Parcel/src/code-flow-identityserver/sample.js
@@ -94,8 +94,9 @@ mgr.events.addUserSignedOut(function (e) {
function clearState() {
mgr.clearStaleState().then(function() {
log("clearStateState success");
- }).catch(function(e) {
- log("clearStateState error", e.message);
+ }).catch(function(err) {
+ console.error(err);
+ log(err);
});
}
@@ -103,6 +104,7 @@ function getUser() {
mgr.getUser().then(function(user) {
log("got user", user);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -111,6 +113,7 @@ function removeUser() {
mgr.removeUser().then(function() {
log("user removed");
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -119,6 +122,7 @@ function querySessionStatus() {
mgr.querySessionStatus().then(function(status) {
log("user's session status", status);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -127,6 +131,7 @@ function revokeAccessToken() {
mgr.revokeAccessToken().then(function() {
log("access token revoked");
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -135,6 +140,7 @@ function startSigninMainWindow() {
mgr.signinRedirect(/*{useReplaceToNavigate:true}*/).then(function() {
log("signinRedirect done");
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -147,6 +153,7 @@ function endSigninMainWindow() {
var theMessage = theState.message;
console.log("here's our post-login state", theMessage);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -155,6 +162,7 @@ function popupSignin() {
mgr.signinPopup().then(function(user) {
log("signed in", user);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -163,14 +171,16 @@ function popupSignout() {
mgr.signoutPopup().then(function() {
log("signed out");
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
function iframeSignin() {
mgr.signinSilent().then(function(user) {
- log("signed in", user);
+ log("signed in silent", user);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -179,6 +189,7 @@ function startSignoutMainWindow() {
mgr.signoutRedirect().then(function(resp) {
log("signed out", resp);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -187,6 +198,11 @@ function endSignoutMainWindow() {
mgr.signoutCallback().then(function(resp) {
log("signed out", resp);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
+
+export {
+ log
+};
diff --git a/samples/Parcel/src/oidc-client/sample-callback.js b/samples/Parcel/src/oidc-client/sample-callback.js
index 09080d0db..399261162 100644
--- a/samples/Parcel/src/oidc-client/sample-callback.js
+++ b/samples/Parcel/src/oidc-client/sample-callback.js
@@ -1,23 +1,12 @@
import { Log, settings } from "./sample-settings";
+import { log } from "./sample";
Log.logger = console;
Log.level = Log.INFO;
-function log() {
- document.getElementById("out").innerText = "";
-
- Array.prototype.forEach.call(arguments, function(msg) {
- if (msg instanceof Error) {
- msg = "Error: " + msg.message;
- }
- else if (typeof msg !== "string") {
- msg = JSON.stringify(msg, null, 2);
- }
- document.getElementById("out").innerHTML += msg + "\r\n";
- });
-}
new OidcClient(settings).processSigninResponse().then(function(response) {
log("signin response success", response);
}).catch(function(err) {
+ console.error(err);
log(err);
});
diff --git a/samples/Parcel/src/oidc-client/sample.js b/samples/Parcel/src/oidc-client/sample.js
index 65d2163f2..39e2e479a 100644
--- a/samples/Parcel/src/oidc-client/sample.js
+++ b/samples/Parcel/src/oidc-client/sample.js
@@ -44,6 +44,7 @@ function signin() {
window.location = req.url;
}
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -54,6 +55,7 @@ function processSigninResponse() {
signinResponse = response;
log("signin response", signinResponse);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -72,6 +74,7 @@ function processSignoutResponse() {
signinResponse = null;
log("signout response", response);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -104,3 +107,7 @@ if (followLinks()) {
processSignoutResponse();
}
}
+
+export {
+ log
+};
diff --git a/samples/Parcel/src/user-manager/sample-callback.js b/samples/Parcel/src/user-manager/sample-callback.js
index 5023570c0..8c21362d6 100644
--- a/samples/Parcel/src/user-manager/sample-callback.js
+++ b/samples/Parcel/src/user-manager/sample-callback.js
@@ -1,7 +1,9 @@
import { UserManager, settings } from "./sample-settings";
+import { log } from "./sample";
new UserManager(settings).signinRedirectCallback().then(function(user) {
console.log("signin response success", user);
}).catch(function(err) {
+ log(err);
console.log(err);
});
diff --git a/samples/Parcel/src/user-manager/sample-popup-signin.js b/samples/Parcel/src/user-manager/sample-popup-signin.js
index 5dabe1b9e..6a0175c76 100644
--- a/samples/Parcel/src/user-manager/sample-popup-signin.js
+++ b/samples/Parcel/src/user-manager/sample-popup-signin.js
@@ -1,3 +1,12 @@
-import { UserManager, settings } from "./sample-settings";
+import { Log, UserManager, settings } from "./sample-settings";
+import { log } from "./sample";
-void new UserManager(settings).signinPopupCallback();
+Log.logger = console;
+Log.level = Log.INFO;
+
+new UserManager(settings).signinPopupCallback().then(function() {
+ log("signin popup callback response success");
+}).catch(function(err) {
+ console.error(err);
+ log(err);
+});
diff --git a/samples/Parcel/src/user-manager/sample-popup-signout.js b/samples/Parcel/src/user-manager/sample-popup-signout.js
index f0af44c7b..6a72cc6dd 100644
--- a/samples/Parcel/src/user-manager/sample-popup-signout.js
+++ b/samples/Parcel/src/user-manager/sample-popup-signout.js
@@ -1,3 +1,12 @@
-import { UserManager, settings } from "./sample-settings";
+import { Log, UserManager, settings } from "./sample-settings";
+import { log } from "./sample";
-void new UserManager(settings).signoutPopupCallback(undefined, true);
+Log.logger = console;
+Log.level = Log.INFO;
+
+new UserManager(settings).signoutPopupCallback(undefined, true).then(function() {
+ log("signout popup callback response success");
+}).catch(function(err) {
+ console.error(err);
+ log(err);
+});
diff --git a/samples/Parcel/src/user-manager/sample-silent.js b/samples/Parcel/src/user-manager/sample-silent.js
index 191b634ab..dbe481b64 100644
--- a/samples/Parcel/src/user-manager/sample-silent.js
+++ b/samples/Parcel/src/user-manager/sample-silent.js
@@ -1,3 +1,12 @@
-import { UserManager, settings } from "./sample-settings";
+import { Log, UserManager, settings } from "./sample-settings";
+import { log } from "./sample";
-void new UserManager(settings).signinSilentCallback();
+Log.logger = console;
+Log.level = Log.INFO;
+
+new UserManager(settings).signinSilentCallback().then(function() {
+ log("signin silent callback response success");
+}).catch(function(err) {
+ console.error(err);
+ log(err);
+});
diff --git a/samples/Parcel/src/user-manager/sample.js b/samples/Parcel/src/user-manager/sample.js
index 5fe15e5c8..93350b26c 100644
--- a/samples/Parcel/src/user-manager/sample.js
+++ b/samples/Parcel/src/user-manager/sample.js
@@ -79,8 +79,9 @@ mgr.events.addUserUnloaded(function (e) {
function clearState() {
mgr.clearStaleState().then(function() {
log("clearStateState success");
- }).catch(function(e) {
- log("clearStateState error", e.message);
+ }).catch(function(err) {
+ console.error(err);
+ log(err);
});
}
@@ -88,6 +89,7 @@ function getUser() {
mgr.getUser().then(function(user) {
log("got user", user);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -96,6 +98,7 @@ function removeUser() {
mgr.removeUser().then(function() {
log("user removed");
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -104,6 +107,7 @@ function startSigninMainWindow() {
mgr.signinRedirect({ state: { some: "data" } }).then(function() {
log("signinRedirect done");
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -112,6 +116,7 @@ function endSigninMainWindow() {
mgr.signinRedirectCallback().then(function(user) {
log("signed in", user);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -120,6 +125,7 @@ function popupSignin() {
mgr.signinPopup().then(function(user) {
log("signed in", user);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -128,6 +134,7 @@ function popupSignout() {
mgr.signoutPopup().then(function() {
log("signed out");
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -136,6 +143,7 @@ function iframeSignin() {
mgr.signinSilent().then(function(user) {
log("signed in", user);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -144,6 +152,7 @@ function startSignoutMainWindow() {
mgr.signoutRedirect().then(function(resp) {
log("signed out", resp);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
@@ -152,6 +161,11 @@ function endSignoutMainWindow() {
mgr.signoutRedirectCallback().then(function(resp) {
log("signed out", resp);
}).catch(function(err) {
+ console.error(err);
log(err);
});
}
+
+export {
+ log
+};