Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 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 = process.env.PORT ?? 3001
const port = 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 All @@ -48,9 +48,7 @@ function onError(error) {
if (error.syscall !== 'listen') {
throw error
}

var bind = `Port ${port}`

const bind = `Port ${port}`
// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
Expand All @@ -70,8 +68,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