-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
index.hbs
48 lines (45 loc) · 1.07 KB
/
index.hbs
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
<!DOCTYPE html>
<html>
<head>
<title>Logging In - Single Sign On - Index</title>
<script type="text/javascript" src="/node_modules/jquery/dist/jquery.js"></script>
<style type="text/css">
body {
padding: 0 10px;
}
</style>
</head>
<body>
<h2>index.html</h2>
<p>
This example uses an XHR to set an x-session-token header.
</p>
<pre id="main"></pre>
<script type="text/javascript">
$(function(){
var token = localStorage.getItem('id_token')
var $main = $('#main')
function noSessionToken() {
$main.text('No session token set!')
}
function gotSessionToken(data) {
$main.text(JSON.stringify(data))
}
if(!token) {
noSessionToken()
} else {
$.ajax({
dataType: 'json',
url: '/config',
beforeSend: function(xhr){
// set the x-session-token request header
xhr.setRequestHeader('x-session-token', token)
}
})
.done(gotSessionToken)
.fail(noSessionToken)
}
})
</script>
</body>
</html>