-
Notifications
You must be signed in to change notification settings - Fork 8
/
app.js
40 lines (38 loc) · 950 Bytes
/
app.js
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
$('.btn-login').click(function() {
$.ajax({
type: 'POST',
url: //'https://<your-auth0-acount>.auth0.com/oauth/ro',
data: {
client_id: // your-auth0-client-id,
username: document.querySelector('#username').value,
password: document.querySelector('#password').value,
grant_type: 'password',
scope: 'openid',
connection:'Username-Password-Authentication'
},
success: function(data) {
getJwtCookie(data.id_token);
},
error: function(error) {
console.log('There was an error: ' + error)
}
});
});
function getJwtCookie(token) {
$.ajax({
type: 'POST',
url: 'http://localhost:3001/secured/authorize-cookie',
data: {
token: token
},
headers: {
'Authorization' : 'Bearer ' + token
},
success: function() {
console.log('Cookie received!');
},
error: function() {
console.log('Problem with cookie');
}
});
}