forked from gabrielsroka/gabrielsroka.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.htm
71 lines (69 loc) · 2.5 KB
/
login.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Sign in</title>
<script src="https://global.oktacdn.com/okta-signin-widget/3.7.1/js/okta-sign-in.min.js" type="text/javascript"></script>
<link href="https://global.oktacdn.com/okta-signin-widget/3.7.1/css/okta-sign-in.min.css" type="text/css" rel="stylesheet" />
</head>
<body>
<br>
<div id="osw-container"></div>
<script>
// see https://developer.okta.com/code/javascript/okta_sign-in_widget
// https://github.com/okta/okta-signin-widget
const config = {
baseUrl: "https://gsroka-neto.oktapreview.com",
idps: [
{type: 'FACEBOOK', id: '0oapxlsjl6WTY02Ur0h7'}
],
i18n: {
// Overriding English properties
'en': {
'primaryauth.title': 'Sign in to Acme',
'errors.E0000004': 'GS: Unable to login \r\n Please click Forgot password link below'
}
}
};
const signIn = new OktaSignIn(config);
if (location.search == "?signout") {
function redirectToLogin() {
location.href = "login.htm";
}
signIn.authClient.signOut()
.then(redirectToLogin)
.fail(redirectToLogin);
} else {
signIn.renderEl(
{el: '#osw-container'},
function success(res) {
if (res.status == "SUCCESS") {
console.log("User %s succesfully authenticated %o", res.user.profile.login, res.user);
res.session.setCookieAndRedirect(location.origin + (new URL(location).searchParams.get('from') || "/home.htm"));
} else {
console.log(res.status);
}
},
function error(err) {
console.log(err);
}
);
signIn.on('ready', function (context) {
console.log('ready', context.controller);
});
signIn.on('afterRender', function (context) {
console.log('afterRender', context.controller);
if (context.controller === 'primary-auth') {
const usernameLabel = document.querySelector("label[for='okta-signin-username']");
const passwordLabel = document.querySelector("label[for='okta-signin-password']");
document.getElementById('okta-signin-username').placeholder = usernameLabel.innerHTML.replace(/ /, ' ');
document.getElementById('okta-signin-password').placeholder = passwordLabel.innerHTML.replace(/ /, ' ');
usernameLabel.innerHTML = '';
passwordLabel.innerHTML = '';
}
});
}
</script>
</body>
</html>