pioneers-token-manager 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
package/index.js CHANGED
@@ -11,15 +11,11 @@ class TokenManager {
11
11
  }
12
12
  verifyToken = (req, res, next) => {
13
13
  const token = extractToken(req);
14
- if (!token) {
15
- sendFail(res, c.statusCodes.UNAUTHORIZED, { message: c.messages.invalidToken });
16
- return;
17
- }
18
14
  try {
19
15
  const decoded = jwt.verify(token, this.tokenKey);
20
16
  req.user = decoded;
21
17
  } catch (err) {
22
- return sendFail(res, c.statusCodes.UNAUTHORIZED, { message: c.messages.invalidToken })
18
+
23
19
  }
24
20
  return next();
25
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pioneers-token-manager",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "a module to verify token",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/client.js DELETED
File without changes
package/config.js DELETED
@@ -1,22 +0,0 @@
1
- const statusCodes = {
2
- SUCCESS: 200,
3
- UNAUTHORIZED: 401
4
- };
5
-
6
- const contentTypes = {
7
- JSON: 'application/json'
8
- };
9
-
10
- const errors = {};
11
-
12
- const messages = {
13
- loginFailed: 'Wrong username or password!',
14
- invalidToken: 'Invalid token!',
15
- };
16
-
17
- module.exports = {
18
- statusCodes,
19
- contentTypes,
20
- errors,
21
- messages,
22
- };
@@ -1,13 +0,0 @@
1
- const c = require('../config');
2
-
3
- module.exports.sendOk = (res, data) => {
4
- res.statusCode = c.statusCodes.SUCCESS;
5
- res.setHeader('Content-Type', c.contentTypes.JSON);
6
- res.end(JSON.stringify(data));
7
- }
8
-
9
- module.exports.sendFail = (res, statusCode, data) => {
10
- res.statusCode = statusCode;
11
- res.setHeader('Content-Type', c.contentTypes.JSON);
12
- res.end(JSON.stringify(data));
13
- }