Browse Source

and also in isAuth

master
Rich Brown 1 year ago
parent
commit
72ee931e39
1 changed files with 2 additions and 3 deletions
  1. +2
    -3
      src/funcs.js

+ 2
- 3
src/funcs.js View File

@@ -2,7 +2,6 @@ import atob from 'atob';

// eslint-disable-next-line import/prefer-default-export
export const isMicropubTokenAuthed = (req, res, next) => {
const { me } = req.body;
const { token } = req.app.locals;
if (!token) return res.status(401).json({ error: "no token, foo'" });

@@ -16,8 +15,8 @@ export const isMicropubTokenAuthed = (req, res, next) => {

// eslint-disable-next-line camelcase
if (now - twoHours > issued_at) {
req.app.locals.tokens[me] = null;
req.app.locals.token = null;
return res.status(401).json({ error: "old token, foo'" });
}
return req.app.locals.tokens[me] ? next() : res.status(403).json({ error: 'NAUGHTY' });
return req.app.locals.token ? next() : res.status(403).json({ error: 'NAUGHTY' });
};

Loading…
Cancel
Save