-
Notifications
You must be signed in to change notification settings - Fork 491
/
Copy pathtest.html
98 lines (83 loc) · 2.7 KB
/
test.html
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html>
<head>
<title>Auth0.js Demo Examples</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//cdn.auth0.com/js/auth0/development/auth0.min.js"></script>
</head>
<body class="container">
<input id="login-username" value="" />
<input id="login-password" type="password" value="" />
<input id="login-scope" value="" />
<input id="login-response-type" value="" />
<input
type="button"
class="login-redirect-usernamepassword"
value="redirect usernamepassword"
/>
<input
type="button"
class="login-redirect-authorize"
value="redirect authorize"
/>
<input type="button" value="logout" class="logout-button" />
<input type="button" class="reset-button" value="reset" />
<div id="err"></div>
<div id="result"></div>
<script type="text/javascript">
var webAuth = new auth0.WebAuth({
domain: 'http://127.0.0.1:3000',
redirectUri: window.location.href,
clientID: 'testing',
leeway: 30,
overrides: {
__token_issuer: 'http://127.0.0.1:3000/'
},
prompt: 'login'
});
$('.login-redirect-usernamepassword').click(function(e) {
e.preventDefault();
webAuth.redirect.loginWithCredentials(
{
connection: 'tests',
username: $('#login-username').val(),
password: $('#login-password').val(),
scope: $('#login-scope').val(),
responseType: $('#login-response-type').val()
},
function(err) {
$('#err').html(JSON.stringify(err));
}
);
});
$('.login-redirect-authorize').click(function(e) {
e.preventDefault();
webAuth.authorize({
scope: $('#login-scope').val(),
responseType: $('#login-response-type').val()
});
});
$('.logout-button').click(function(e) {
e.preventDefault();
webAuth.logout({ returnTo: 'http://127.0.0.1:3000/test.html' });
});
$('.reset-button').click(function(e) {
e.preventDefault();
window.location.href = 'http://127.0.0.1:3000/test.html';
});
webAuth.parseHash(function(err, result) {
if (err) {
$('#err').html(JSON.stringify(err));
$(document.body).append($('<div id="parsed"></div>'));
}
if (result) {
$('#result').html(JSON.stringify(result));
$(document.body).append($('<div id="parsed"></div>'));
}
});
$(document).ready(function() {
$(document.body).append($('<div id="loaded"></div>'));
});
</script>
</body>
</html>