Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jminutaglio authored Apr 18, 2023
1 parent 5f63d34 commit 744f9d7
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions function-source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ exports.horoscopeAPIprod = async (req, res) => {
const horoscopeJSON = require('./config.json');

// Define tokens & create a nested object for the subscriptions:
const validTokens = ['2', 'mmEUtLATc8w_UNnHuR2'];
const tokenData = {
const tokenJSON = {
'2': {
name: 'Expired Token Ex',
expiration: '03-31-2020'
Expand All @@ -78,10 +77,6 @@ exports.horoscopeAPIprod = async (req, res) => {
},
};

// Convert the object to a JSON object
const tokenJSONStr = JSON.stringify(tokenData);
const tokenJSON = JSON.parse(tokenJSONStr);

console.info('Received request -> ' + req.method);

// Retrieve the date and sign parameters from the query string or request body
Expand Down Expand Up @@ -121,7 +116,7 @@ exports.horoscopeAPIprod = async (req, res) => {
return;
}

if (!validTokens.includes(token.toString())) {
if (!tokenJSON[token.toString()]) {
let badToken = '401 - Unauthorized -> Token is not authorized: ' + token;
console.info(badToken);
res.status(401).send('Unauthorized');
Expand Down

0 comments on commit 744f9d7

Please sign in to comment.