-
Notifications
You must be signed in to change notification settings - Fork 290
/
login.html
42 lines (40 loc) · 1.31 KB
/
login.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
<html>
<h1>Redirecting...</h1>
<script>
// config vars, TODO move to something more configurable
var redirect_uri = "https://wolf.cci.emory.edu/camic_uat/login.html"
var audience = "wolf.cci.emory.edu/camic_uat"
var scope = "openid%20email"
var client_id = "YLRDUmEs5Jivi6FX3XtNNAt97X3a0epD"
var response_type = "id_token"
var base_auth_url = "https://birmstuff.auth0.com/authorize?"
var cookie_name = "token" // "token" is expected by elevate router
// make the url
var auth_url = base_auth_url
auth_url += "&audience=" + audience
auth_url += "&scope=" + scope
auth_url += "&response_type=" + response_type
auth_url += "&client_id=" + client_id
auth_url += "&redirect_uri=" + redirect_uri
function getUrlParam(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
// get variables
let id_token = getUrlParam("id_token")
let state = getUrlParam("state")
// is this a login pre or post?
if (id_token){
document.cookie = cookie_name +"=" + id_token;
window.location = state
} else {
auth_url += "&state=" + state
window.location = auth_url
}
</script>
<html>