Skip to content

Commit

Permalink
fixes #167
Browse files Browse the repository at this point in the history
  • Loading branch information
cubap committed Nov 25, 2024
1 parent 5bfeb7c commit 545e454
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
10 changes: 5 additions & 5 deletions bin/rerum_v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ dotenv.config()
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT ?? '3001')
const port = normalizePort(process.env.PORT ?? '3001')
app.set('port', port)

/**
* Create HTTP server.
*/

var server = http.createServer(app)
const server = http.createServer(app)

/**
* Listen on provided port, on all network interfaces.
Expand Down Expand Up @@ -69,7 +69,7 @@ function onError(error) {
throw error
}

var bind = typeof port === 'string'
const bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port

Expand All @@ -94,8 +94,8 @@ function onError(error) {

function onListening() {
console.log("LISTENING ON "+port)
var addr = server.address()
var bind = typeof addr === 'string'
const addr = server.address()
const bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port
debug('Listening on ' + bind)
Expand Down
52 changes: 28 additions & 24 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
<html lang="en-us">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="RERUM Authorization Portal">
<meta name="author" content="Research Computing Group, Saint Louis University">
<meta name="keywords" content="RERUM, Auth0, API, RESTful, compliant, open, free, attributed, versioned">
<title>RERUM Authorization Portal</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
Expand Down Expand Up @@ -109,23 +113,23 @@ <h1 onclick="window.location='https://rerum.io'" target="_blank" class="navbar-b
Interacting with RERUM requires server-to-server communication, so we suggest the registrant be the
application developer.
You may want to
<a target="_blank" href="https://rerum.io/#/future"
<a target="_blank" rel="noopener" href="https://rerum.io/#/future"
class="linkOut">learn more about the concepts around RERUM</a>
before reading the API.
</p>
<p class="handHoldy">
If you are here for the first time and think you want to use RERUM, please
<a target="_blank" href="https://store.rerum.io/API.html"
<a target="_blank" rel="noopener" href="https://store.rerum.io/API.html"
class="linkOut">read the API</a> first.
</p>

<p class="handHoldy">
If you like what you read in <a target="_blank"
If you like what you read in <a target="_blank" rel="noopener"
href="https://store.rerum.io/API.html"
class="linkOut">our API documentation</a>
and want to begin using RERUM as a back stack service please register by clicking below.
Be prepared to be routed to Auth0 (don't know why?
<a target="_blank" href="https://store.rerum.io/API.html"
<a target="_blank" rel="noopener" href="https://store.rerum.io/API.html"
class="linkOut">Read the API</a>).
</p>
<p class="handHoldy">
Expand Down Expand Up @@ -234,11 +238,11 @@ <h1 onclick="window.location='https://rerum.io'" target="_blank" class="navbar-b
* https://auth0.com/docs/api-auth/tutorials/client-credentials
* TEST
*/
var access_token = ""
var auth_code = ""
var error_code = ""
var responseJSON = {}
var myURL = document.location.href
let access_token = ""
let auth_code = ""
let error_code = ""
let responseJSON = {}
const myURL = document.location.href

if (myURL.indexOf("access_token=") > -1) {
//The user registered or asked for a new token through the Client Credentials Grant flow https://auth0.com/docs/api-auth/tutorials/client-credentials
Expand Down Expand Up @@ -297,7 +301,7 @@ <h1 onclick="window.location='https://rerum.io'" target="_blank" class="navbar-b
},
body: JSON.stringify({ refresh_token })
}).then(resp => {
var statusElem = $("#natStatus");
const statusElem = $("#natStatus");
if (resp.status < 300) {
statusElem.html("The refresh token was accepted.")
return resp.json()
Expand All @@ -314,7 +318,7 @@ <h1 onclick="window.location='https://rerum.io'" target="_blank" class="navbar-b

$("#refresh_token").click(function () {
//The user would like to request a new access token using the refresh token. Send them off to log in.
var authorization_code = $("#code_for_refresh_token").val()
const authorization_code = $("#code_for_refresh_token").val()
if (!authorization_code) {
$("#code_for_refresh_token").attr("placeholder", "You must supply a code here!")
$("#code_for_refresh_token").css("border", "2px solid yellow")
Expand All @@ -331,7 +335,7 @@ <h1 onclick="window.location='https://rerum.io'" target="_blank" class="navbar-b
},
body: JSON.stringify({ authorization_code })
}).then(resp => {
var statusElem = $("#nrtStatus")
const statusElem = $("#nrtStatus")
if (resp.status < 300) {
statusElem.html("Auth0 accepted the code.")
return resp.json()
Expand Down Expand Up @@ -359,36 +363,36 @@ <h1 onclick="window.location='https://rerum.io'" target="_blank" class="navbar-b
// `https://cubap.auth0.com/authorize?response_type=code&client_id=62Jsa9MxHuqhRbO20gTHs9KpKr7Ue7sl&redirect_uri=http://store.rerum.io&state=STATE`)

function getURLVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
const query = window.location.search.substring(1);
const vars = query.split("&");
for (let i = 0; i < vars.length; i++) {
const pair = vars[i].split("=");
if (pair[0] == variable) { return pair[1]; }
}
return false;
}

function getURLHash(variable) {
var query = document.location.hash;
let query = document.location.hash;
query = query.substr(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
const vars = query.split("&");
for (let i = 0; i < vars.length; i++) {
const pair = vars[i].split("=");
if (pair[0] == variable) { return pair[1]; }
}
return false;
}

function testAPI() {
var userProvidedToken = $("#a_t").val()
const userProvidedToken = $("#a_t").val()
if (!userProvidedToken) {
$("#a_t").attr("placeholder", "You must supply an access token here!")
$("#a_t").css("border", "2px solid yellow")
return false
}

$("#a_t").css("border", "none")
var statusElem = $("#rerumStatus")
$("#a_t").css("bordnser", "none"t)
const statusElem = $("#rerumStatus")
statusElem.html("WORKING...")

fetch('/client/verify', {
Expand Down

0 comments on commit 545e454

Please sign in to comment.