Skip to content

Commit

Permalink
more automatic login page
Browse files Browse the repository at this point in the history
  • Loading branch information
birm committed Apr 3, 2019
1 parent f3d8c41 commit 8175ce0
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions login.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<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 default_redirect = "https://wolf.cci.emory.edu/camic_uat/viewer.html"
// config vars, these are DEFAULTS
var audience = "wolf.cci.emory.edu/camic_uat"
var scope = "openid%20email"
var client_id = "YLRDUmEs5Jivi6FX3XtNNAt97X3a0epD"
// handle urls automatically
var base_deployment_url = window.location.toString().split("/").slice(0,-1).join("/")
var redirect_uri = base_deployment_url + "/login.html"
var default_redirect = base_deployment_url + "/apps/table.html"
var response_type = "id_token"
var base_auth_url = "https://birmstuff.auth0.com/authorize?"
var cookie_name = "token" // "token" is expected by elevate router
Expand Down Expand Up @@ -47,8 +49,22 @@ <h1>Redirecting...</h1>
}
// is this a login pre or post?
if (id_token){
document.cookie = cookie_name +"=" + id_token;
window.location = state
document.cookie = cookie_name + "=" + id_token;
fetch("./auth/Token/check",
{headers: {
'Authorization': "Bearer " + id_token
}}
).then(x=>x.json()).then(x=>{
console.log("{id provider", id_token)
console.log("{auth service}", x)
if (x.hasOwnProperty('token')){
document.cookie = cookie_name + "=" + x.token;
window.location = state
} else {
console.error("please give me a better failure message/response")
}

})
} else {
window.localStorage.setItem('nonce', randomString(16));
auth_url += "&state=" + state
Expand Down

0 comments on commit 8175ce0

Please sign in to comment.