forgerockembeddedlogin
Version:
Library to assist with login for ForgeRock web clients
51 lines (48 loc) • 1.89 kB
HTML
<html>
<head>
<script src="ForgeRockEmbeddedLoginBundle.js"></script>
<style>
#loginPanel {
position: absolute;
display: block;
width: 300px;
height: 200px;
border: thin black solid;
}
</style>
</head>
<body>
<h1 id="loginHeader"></h1>
<div id="loginPanel"></div>
</body>
<script>
var login = new ForgeRockEmbeddedLogin({
authenticateUrl: "https://sample.iam.forgeops.com/am/json/realms/root/authenticate",
loginElement: document.getElementById("loginPanel"),
postRenderHandler: function (header, stage, template) {
document.getElementById("loginHeader").innerHTML = header;
},
successHandler: function() {
document.getElementById("loginHeader").innerHTML = "Logged In!";
this.loginElement.innerHTML = '';
},
failureHandler: function() {
document.getElementById("loginHeader").innerHTML = "Login Failure!";
setTimeout(() => this.startLogin(), 2000);
}
});
/* Example for how to customize various callbacks:
login.renderNameCallback = function (callback, index, prompt) {
let el = document.createElement("div");
el.innerHTML = `<label>${prompt} : <input type="text" name="callback_${index}" value="${callback.input[0].value}"></label>`;
return Promise.resolve(el.firstElementChild);
};
login.renderPasswordCallback = function (callback, index, prompt) {
let el = document.createElement("div");
el.innerHTML = `<label>${prompt} : <input type="password" name="callback_${index}" value="${callback.input[0].value}"></label>`;
return Promise.resolve(el.firstElementChild);
};
*/
login.startLogin();
</script>
</html>