Skip to content

Commit 8bf3e2b

Browse files
cubapthehabes
andauthored
fixes #167 (#182)
Co-authored-by: Bryan Haberberger <bryan.j.haberberger@slu.edu>
1 parent ba34f82 commit 8bf3e2b

File tree

2 files changed

+33
-31
lines changed

2 files changed

+33
-31
lines changed

bin/rerum_v1.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ dotenv.config()
1515
* Get port from environment and store in Express.
1616
*/
1717

18-
var port = process.env.PORT ?? 3001
18+
const port = process.env.PORT ?? 3001
1919
app.set('port', port)
2020

2121
/**
2222
* Create HTTP server.
2323
*/
2424

25-
var server = http.createServer(app)
25+
const server = http.createServer(app)
2626

2727
/**
2828
* Listen on provided port, on all network interfaces.
@@ -48,9 +48,7 @@ function onError(error) {
4848
if (error.syscall !== 'listen') {
4949
throw error
5050
}
51-
52-
var bind = `Port ${port}`
53-
51+
const bind = `Port ${port}`
5452
// handle specific listen errors with friendly messages
5553
switch (error.code) {
5654
case 'EACCES':
@@ -70,8 +68,8 @@ function onError(error) {
7068

7169
function onListening() {
7270
console.log("LISTENING ON "+port)
73-
var addr = server.address()
74-
var bind = typeof addr === 'string'
71+
const addr = server.address()
72+
const bind = typeof addr === 'string'
7573
? 'pipe ' + addr
7674
: 'port ' + addr.port
7775
debug('Listening on ' + bind)

public/index.html

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
<html lang="en-us">
33

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

122126
<p class="handHoldy">
123-
If you like what you read in <a target="_blank"
127+
If you like what you read in <a target="_blank" rel="noopener"
124128
href="https://store.rerum.io/API.html"
125129
class="linkOut">our API documentation</a>
126130
and want to begin using RERUM as a back stack service please register by clicking below.
127131
Be prepared to be routed to Auth0 (don't know why?
128-
<a target="_blank" href="https://store.rerum.io/API.html"
132+
<a target="_blank" rel="noopener" href="https://store.rerum.io/API.html"
129133
class="linkOut">Read the API</a>).
130134
</p>
131135
<p class="handHoldy">
@@ -234,11 +238,11 @@ <h1 onclick="window.location='https://rerum.io'" target="_blank" class="navbar-b
234238
* https://auth0.com/docs/api-auth/tutorials/client-credentials
235239
* TEST
236240
*/
237-
var access_token = ""
238-
var auth_code = ""
239-
var error_code = ""
240-
var responseJSON = {}
241-
var myURL = document.location.href
241+
let access_token = ""
242+
let auth_code = ""
243+
let error_code = ""
244+
let responseJSON = {}
245+
const myURL = document.location.href
242246

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

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

361365
function getURLVariable(variable) {
362-
var query = window.location.search.substring(1);
363-
var vars = query.split("&");
364-
for (var i = 0; i < vars.length; i++) {
365-
var pair = vars[i].split("=");
366+
const query = window.location.search.substring(1);
367+
const vars = query.split("&");
368+
for (let i = 0; i < vars.length; i++) {
369+
const pair = vars[i].split("=");
366370
if (pair[0] == variable) { return pair[1]; }
367371
}
368372
return false;
369373
}
370374

371375
function getURLHash(variable) {
372-
var query = document.location.hash;
376+
let query = document.location.hash;
373377
query = query.substr(1);
374-
var vars = query.split("&");
375-
for (var i = 0; i < vars.length; i++) {
376-
var pair = vars[i].split("=");
378+
const vars = query.split("&");
379+
for (let i = 0; i < vars.length; i++) {
380+
const pair = vars[i].split("=");
377381
if (pair[0] == variable) { return pair[1]; }
378382
}
379383
return false;
380384
}
381385

382386
function testAPI() {
383-
var userProvidedToken = $("#a_t").val()
387+
const userProvidedToken = $("#a_t").val()
384388
if (!userProvidedToken) {
385389
$("#a_t").attr("placeholder", "You must supply an access token here!")
386390
$("#a_t").css("border", "2px solid yellow")
387391
return false
388392
}
389393

390-
$("#a_t").css("border", "none")
391-
var statusElem = $("#rerumStatus")
394+
$("#a_t").css("bordnser", "none"t)
395+
const statusElem = $("#rerumStatus")
392396
statusElem.html("WORKING...")
393397

394398
fetch('/client/verify', {

0 commit comments

Comments
 (0)