Skip to content

Commit

Permalink
HOTFIX: don't test in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
Ratstail91 committed Dec 23, 2023
1 parent 288e584 commit 58bc3f6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth-server",
"version": "1.8.3",
"version": "1.8.4",
"description": "An API centric auth server. Uses Sequelize and mariaDB by default.",
"main": "server/server.js",
"scripts": {
Expand Down
10 changes: 3 additions & 7 deletions server/utilities/token-decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ module.exports = (req, res, next) => {
return res.status(401).send('No access token provided');
}

return jwt.decode(accessToken, process.env.SECRET_ACCESS, (err, user) => {
if (err) {
return res.status(403).send(err);
}
const decoded = jwt.decode(accessToken);

req.user = user;
req.user = decoded.payload;

return next();
});
return next();
};
9 changes: 9 additions & 0 deletions tools/react/token-provider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ const TokenProvider = props => {
//ping the auth server for a new access token
const response = await fetch(`${process.env.AUTH_URI}/auth/token`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${bearer}`
},
credentials: 'include'
});

Expand Down Expand Up @@ -79,13 +82,19 @@ const TokenProvider = props => {

//access the refreshed token via callback
const tokenCallback = async (cb) => {
//use this?
let bearer = accessToken;

//if expired (10 minutes, normally)
const expired = new Date(decode(accessToken).exp) < Date.now() / 1000;

if (expired) {
//ping the auth server for a new token
const response = await fetch(`${process.env.AUTH_URI}/auth/token`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${bearer}`
},
credentials: 'include'
});

Expand Down

0 comments on commit 58bc3f6

Please sign in to comment.