Skip to content

updated dependencies and fixed params being passed to hooks #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 9 additions & 9 deletions Configs/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ function generateToken(data)
return sha256.update(data).digest("base64");
}

exports.validateClient = function (clientId, clientSecret, cb)
exports.validateClient = function (clientCredentials, req, cb)
{
// Call back with `true` to signal that the client is valid, and `false` otherwise.
// Call back with an error if you encounter an internal server error situation while trying to validate.
Client.findOne({ client: clientId, secret: clientSecret }, function (err, client) {
Client.findOne({ client: clientCredentials.clientId, secret: clientCredentials.clientSecret }, function (err, client) {
if(err){
cb(null, false);
}else {
Expand All @@ -49,25 +49,25 @@ exports.validateClient = function (clientId, clientSecret, cb)
});
};

exports.grantUserToken = function (username, password, cb)
exports.grantUserToken = function (allCredentials, req, cb)
{
var query = User.where( 'username', new RegExp('^' + username + '$', 'i') );
var query = User.where( 'username', new RegExp('^' + allCredentials.username + '$', 'i') );

query.findOne(function (err, user) {
if (err) {
cb(null, false);
} else if (!user) {
cb(null, false);
} else if (user.authenticate(password)) {
} else if (user.authenticate(allCredentials.password)) {
// If the user authenticates, generate a token for them and store it to the database so
// we can look it up later.

var token = generateToken(username + ":" + password);
var newToken = new Token({ username: username, token: token });
var token = generateToken(allCredentials.username + ":" + allCredentials.password);
var newToken = new Token({ username: allCredentials.username, token: token });
newToken.save();

// Store the token in the Redis datastore so we can perform fast queries on it
redisClient.set(token, username);
redisClient.set(token, allCredentials.username);

// Call back with the token so Restify-OAuth2 can pass it on to the client.
return cb(null, token);
Expand All @@ -77,7 +77,7 @@ exports.grantUserToken = function (username, password, cb)
});
};

exports.authenticateToken = function (token, cb)
exports.authenticateToken = function (token, req, cb)
{
// Query the Redis store for the Auth Token
redisClient.get(token, function (err, reply) {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Installation
- Install dependancies: `npm install`
- Start redis: `redis-server`
- Start MongoDB: `mongod`
- Insert a Client Key into the mongoDB wit the format:
- Insert a Client Key into the mongoDB with the format:

```JSON
{
Expand Down
5 changes: 3 additions & 2 deletions node_modules/bcrypt/.travis.yml

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

46 changes: 0 additions & 46 deletions node_modules/bcrypt/CHANGELOG

This file was deleted.

173 changes: 76 additions & 97 deletions node_modules/bcrypt/README.md

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

Loading