Comparing version 0.2.1 to 0.3.0
17
index.js
@@ -46,19 +46,8 @@ //Global variables | ||
} else { | ||
console.log("getting") | ||
//If we do have a token in the header... | ||
redis.get(req.headers[config.header], function(err,response) { | ||
console.log("success") | ||
req.auth = response | ||
if (err) { | ||
if (config.returnError == true) { | ||
return res.status(500).send({ | ||
"error": true, | ||
"status": 500, | ||
"message": "Redis error..." | ||
}) | ||
} else { | ||
req.error = true | ||
req.errorType = "Redis error..." | ||
req.errorCode = 500 | ||
return next() | ||
} | ||
} else { | ||
if (err) { return res.status(500).send(err) } else { | ||
//Check permissions via grant type | ||
@@ -65,0 +54,0 @@ if (Array.isArray(permissions)) { |
{ | ||
"name": "redis.auth", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "A non prescriptive Redis Authentication module for Express", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -20,3 +20,3 @@ [![Build Status](https://travis-ci.org/ChrisCates/redis.auth.svg?branch=master)](https://travis-ci.org/ChrisCates/redis.auth) | ||
``` | ||
``` javascript | ||
var redis = require("redis.token")() | ||
@@ -35,3 +35,3 @@ var auth = require("redis.auth")(redis, { | ||
### Example Express middleware | ||
``` | ||
``` javascript | ||
var express = require("express") | ||
@@ -44,2 +44,3 @@ var app = express() | ||
app.get("/user", auth("user"), function(req,res) { | ||
//req.auth = stored Redis.Token Object | ||
return res.status(200).send("Only users can access this...") | ||
@@ -50,2 +51,3 @@ }) | ||
app.get("/user", auth(["user", "admin"]), function(req,res) { | ||
//req.auth = stored Redis.Token Object | ||
return res.status(200).send("Admins and users can access this...") | ||
@@ -64,4 +66,3 @@ }) | ||
``` | ||
req.auth = {Redis Object} | ||
``` javascript | ||
return res.status(403).send({ | ||
@@ -76,4 +77,3 @@ "error": true, | ||
``` | ||
req.auth = {Redis Object} | ||
``` javascript | ||
//Sets these variables in req so you can check for them on your own | ||
@@ -80,0 +80,0 @@ req.error = true |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
0
26752
6
85
1