Skip to content

Commit

Permalink
pre-test login
Browse files Browse the repository at this point in the history
  • Loading branch information
birm committed Oct 16, 2018
1 parent 3e072a1 commit e50a966
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<html>
<h1>Redirecting...</h1>
<script>
// config vars, TODO move to something more configurable
var redirect_uri = "https://YOUR_APP/callback"
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>

0 comments on commit e50a966

Please sign in to comment.