express-user
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -61,3 +61,3 @@ //Copyright (c) 2015 Eric Vallee <eric_vallee2003@yahoo.ca> | ||
GetRoutingVars(Req, Res, Next, function(RoutingVars) { | ||
UserStore.Update(RoutingVars['User'], RoutingVars['Update'], function(Err, Result) { | ||
var Callback = function(Err, Result) { | ||
if(Err) | ||
@@ -88,3 +88,13 @@ { | ||
} | ||
}); | ||
}; | ||
//Technically, could just call UpdateAtomic for both cases, but the Update call is kept for backward-compatibility reasons until version 2.x.x | ||
if(!RoutingVars['Memberships']) | ||
{ | ||
UserStore.Update(RoutingVars['User'], RoutingVars['Update'], Callback); | ||
} | ||
else | ||
{ | ||
UserStore.UpdateAtomic(RoutingVars['User'], RoutingVars['Update'], RoutingVars['Memberships'], Callback); | ||
} | ||
}); | ||
@@ -91,0 +101,0 @@ }); |
{ | ||
"name": "express-user", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Ressource Oriented Express Middleware to Manage Users.", | ||
@@ -36,3 +36,3 @@ "keywords": [ | ||
"user-properties": "^3.1.0", | ||
"user-store": "^2.0.0" | ||
"user-store": "^2.1.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "license": "MIT", |
@@ -160,2 +160,4 @@ Express-User | ||
res.locals.ExpressUser.Memberships: Optional input that specifies memberships to add/remove. Its expected format is the same as the 'Memberships' argument for the 'UpdateAtomic' method in the 'user-store' project. API compliance with user-store version 2.1.0 or higher is required. | ||
- DELETE /User/Self and DELETE /User/:Field/:ID | ||
@@ -283,5 +285,5 @@ | ||
- A recent version of Node.js (version 0.10.25 is installed on my machine) [1] | ||
- A recent version of Node.js (version 0.10.25 is installed on my machine) \[1\] | ||
- A recent version of Express.js (version 4.x, the library uses Express.Router()) [1] | ||
- A recent version of Express.js (version 4.x, the library uses Express.Router()) \[1\] | ||
@@ -307,3 +309,3 @@ - Either the user-store project (and accompanying dependencies) or a user store that has the same API as the user-store project | ||
Note that the remainder of this library is not dependent on your using its session support so you opt not to use it and still use the rest of the library. You simply need not to handle the session routes in your validator and express-user will trigger an error handler when those routes are encountered, which you can deal with in your validator (and maybe return 404). | ||
Note that the remainder of this library is not dependent on your using its session support so you opt not to use it and still use the rest of the library. You simply need not to handle the session routes in your validator and express-user will trigger an error handler when those routes are encountered, which you can deal with in your responder (probably by returning 404). | ||
@@ -378,2 +380,9 @@ Security Note About Validator | ||
1.1.0 | ||
----- | ||
- Added support for the validator to indicate membership(s) to add/remove in the PATCH /User/Self and PATCH /User/:Field/:ID routes | ||
- Update dev dependency for user-store to version 2.1.0 | ||
- Corrected small error in documentation | ||
1.0.3 | ||
@@ -380,0 +389,0 @@ ----- |
@@ -21,2 +21,13 @@ //Copyright (c) 2015 Eric Vallee <eric_vallee2003@yahoo.ca> | ||
function In() | ||
{ | ||
var InList = arguments[0]; | ||
var CheckList = Array.prototype.slice.call(arguments, 1); | ||
return(CheckList.every(function(CheckItem) { | ||
return(InList.some(function(RefItem) { | ||
return RefItem===CheckItem; | ||
})); | ||
})); | ||
} | ||
function Middleware(Routes) | ||
@@ -200,2 +211,6 @@ { | ||
} | ||
if(Req.body.Memberships) | ||
{ | ||
Res.locals.ExpressUser.Memberships = Req.body.Memberships; | ||
} | ||
} | ||
@@ -414,2 +429,19 @@ Next(); | ||
}, | ||
'UserModification + Memberships': function(Test) { | ||
Test.expect(2); | ||
var Requester = new RequestHandler(); | ||
Requester.Request('POST', '/Users', function(Status, Body) { | ||
Requester.Request('PATCH', '/User/Self', function(Status, Body) { | ||
Context['UserStore'].Get({'Username': 'SomeName2'}, function(Err, User) { | ||
Test.ok(User && User.Memberships && User.Memberships.length === 2 && In(User.Memberships, 'Test1', 'Test2'), "Confirming that PATCH requests with Memberships manipulations work, part 1."); | ||
Requester.Request('PATCH', '/User/Self', function(Status, Body) { | ||
Context['UserStore'].Get({'Username': 'SomeName3'}, function(Err, User) { | ||
Test.ok(User && User.Memberships && User.Memberships.length === 1 && In(User.Memberships, 'Test1'), "Confirming that PATCH requests with Memberships manipulations work, part 2."); | ||
Test.done(); | ||
}); | ||
}, {'User': {'Username': 'SomeName2'}, 'Update': {'Username': 'SomeName3'}, 'Memberships': {'Remove': 'Test2'}}); | ||
}); | ||
}, {'User': {'Username': 'SomeName'}, 'Update': {'Username': 'SomeName2'}, 'Memberships': {'Add': ['Test1', 'Test2']}}); | ||
}, {'User': {'Username': 'SomeName', 'Email': 'SomeEmail@Email.com', 'Password': 'Qwerty!'}}, true); | ||
}, | ||
'SessionSync': function(Test) { | ||
@@ -416,0 +448,0 @@ Test.expect(2); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137134
787
514