Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

express-user

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-user - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

26

lib/ExpressUser.js

@@ -76,3 +76,3 @@ //Copyright (c) 2015 Eric Vallee <eric_vallee2003@yahoo.ca>

}
else if(Result==0)
else if(Result === 0 || Result === null)
{

@@ -86,13 +86,31 @@ var Err = new Error();

{
if(RoutingVars['GetUpdatedUser'])
{
RoutingVars['Result'] = Result;
}
Next();
}
};
//Technically, could just call UpdateAtomic for both cases, but the Update call is kept for backward-compatibility reasons until version 2.x.x
//Technically, could just call UpdateAtomic/UpdateGetAtomic 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);
if(RoutingVars['GetUpdatedUser'])
{
UserStore.UpdateGet(RoutingVars['User'], RoutingVars['Update'], Callback);
}
else
{
UserStore.Update(RoutingVars['User'], RoutingVars['Update'], Callback);
}
}
else
{
UserStore.UpdateAtomic(RoutingVars['User'], RoutingVars['Update'], RoutingVars['Memberships'], Callback);
if(RoutingVars['GetUpdatedUser'])
{
UserStore.UpdateGetAtomic(RoutingVars['User'], RoutingVars['Update'], RoutingVars['Memberships'], Callback);
}
else
{
UserStore.UpdateAtomic(RoutingVars['User'], RoutingVars['Update'], RoutingVars['Memberships'], Callback);
}
}

@@ -99,0 +117,0 @@

4

package.json
{
"name": "express-user",
"version": "1.1.1",
"version": "1.2.0",
"description": "Ressource Oriented Express Middleware to Manage Users.",

@@ -36,3 +36,3 @@ "keywords": [

"user-properties": "^3.1.0",
"user-store": "^2.1.0"
"user-store": "^2.4.2"
},

@@ -39,0 +39,0 @@ "license": "MIT",

@@ -162,2 +162,4 @@ Express-User

If res.locals.ExpressUser.GetUpdatedUser contains a truthy value, the user's entire updated profile will be returned in res.locals.ExpressUser.Result
- DELETE /User/Self and DELETE /User/:Field/:ID

@@ -200,2 +202,4 @@

res.locals.ExpressUser.Update: Should contain the new values of fields that are to be modified
If res.locals.ExpressUser.GetUpdatedUser contains a truthy value, the user's entire updated profile will be returned in res.locals.ExpressUser.Result

@@ -229,3 +233,3 @@ Intercomponent Communication: Output

Otherwise, no properties are set.
Otherwise, no properties are set except the following: if res.locals.ExpressUser.GetUpdatedUser was a truthy value, res.locals.ExpressUser.Result will be defined and it will contain the an object representing the updated user.

@@ -291,3 +295,3 @@ - DELETE /User/Self and DELETE /User/:Field/:ID

- Either the user-store project (and accompanying dependencies) or a user store that has the same API as the user-store project
- Either the user-store project (and accompanying dependencies) or a user store that has the same API as the user-store project \[2\]

@@ -298,4 +302,6 @@ - For an "out of the box" solution, you'll also need a validator and a responder. express-user-local and express-user-local-basic can provide those for you for local authentication.

[1] If it doesn't work for later version, please let me know.
\[1\] If it doesn't work for later version, please let me know.
\[2\] Latest version of user-store is always preferable. While previously existing features don't require a user-store update, new features to this library are often dependent on new user-store features. I always update the dev dependency of user-store for tests when needed so release notes are a good indicator of which features require which version of user-store.
Session Dependency

@@ -377,2 +383,8 @@ ------------------

1.2.0
-----
- Added support for retrieving the user's entire updated profile (in case the responder needs it) for the PATCH /User/Self, PATCH /User/:Field/:ID, POST /User/Self/Recovery/:SetField and POST /User/:Field/:ID/Recovery/:SetField routes.
- Updated dev dependency for user-store to version 2.4.2
1.1.1

@@ -388,3 +400,3 @@ -----

- 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
- Updated dev dependency for user-store to version 2.1.0
- Corrected small error in documentation

@@ -391,0 +403,0 @@

@@ -214,2 +214,6 @@ //Copyright (c) 2015 Eric Vallee <eric_vallee2003@yahoo.ca>

}
if(Req.body.GetUpdatedUser)
{
Res.locals.ExpressUser.GetUpdatedUser = Req.body.GetUpdatedUser;
}
}

@@ -220,3 +224,3 @@ Next();

var SuccessRoute = {'Method': 'use', 'Path': '/', 'Call': function(Req, Res, Next) {
if(!(Res.locals.ExpressUser && Res.locals.ExpressUser.Result!==undefined))
if(!(Res.locals.ExpressUser && Res.locals.ExpressUser.Result !== undefined))
{

@@ -494,4 +498,37 @@ Res.status(200).end();

Nimble.series(Calls, function(Err) {Test.done();});
},
'GetUpdatedUser': function(Test) {
Test.expect(16);
var Requester = new RequestHandler();
function TestRoute(Method, URL, Name, Callback)
{
Requester.Request('POST', '/Users', function(Status, Body) {
Requester.Request(Method, URL, function(Status, Body) {
Test.ok(Body && Body.Username === (Name+2) && Body.Email === (Name+2+'@Email.com'), "Confirming that User is retrieved when GetUpdatedUser is true for "+Method+" "+URL+" route.");
Requester.Request(Method, URL, function(Status, Body) {
Test.ok(Body && Body.ErrType && Body.ErrType === 'NoUpdate', "Confirming that proper error mechanism is triggered for updating non-existent user when GetUpdatedUser is true for "+Method+" "+URL+" route.");
Requester.Request(Method, URL, function(Status, Body) {
Test.ok(Status === 200 && Body === null, "Confirming that User is not retrieved when GetUpdatedUser is falsey "+Method+" "+URL+" route.");
Requester.Request('POST', '/Users', function(Status, Body) {
Requester.Request(Method, URL, function(Status, Body) {
Test.ok(Body && Body.ErrSource === 'UserStore' && Body.ErrType === 'StoreConstraint', "Confirming that proper error mechanism is triggered for violating user store constraint when GetUpdatedUser is true for "+Method+" "+URL+" route.");
Callback();
}, {'User': {'Username': Name+3}, 'Update': {'Username': Name+100, 'Email': Name+100+'@Email.com'}, 'GetUpdatedUser': true}, true);
}, {'User': {'Username': Name+100, 'Email': Name+100+'@Email.com', 'Password': 'Qwerty!'}}, true);
}, {'User': {'Username': Name+2}, 'Update': {'Username': Name+3, 'Email': Name+3+'@Email.com'}, 'GetUpdatedUser': false}, true);
}, {'User': {'Username': Name}, 'Update': {'Username': Name+2, 'Email': Name+2+'@Email.com'}, 'GetUpdatedUser': true}, true);
}, {'User': {'Username': Name}, 'Update': {'Username': Name+2, 'Email': Name+2+'@Email.com'}, 'GetUpdatedUser': true}, true);
}, {'User': {'Username': Name, 'Email': Name+'@Email.com', 'Password': 'Qwerty!'}}, true);
}
TestRoute('PATCH', '/User/Username/SomeName', 'SomeName', function() {
TestRoute('PATCH', '/User/Self', 'DoNotCare', function() {
TestRoute('POST', '/User/Self/Recovery/Password', 'HahaHaha', function() {
TestRoute('POST', '/User/Self/Recovery/Password', 'HihiHihi', function() {
Test.done();
});
});
});
});
}
};

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc