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

@warp-works/core

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@warp-works/core - npm Package Compare versions

Comparing version 1.0.0-rc1 to 1.0.0-rc2

test-authenticate.js

40

lib/models/domain.js
const _ = require('lodash');
// const debug = require('debug')('W2:models:domain');
const fs = require('fs');
const Promise = require('bluebird');

@@ -13,2 +14,7 @@ const Base = require('./base');

// TODO: Fix this hard-coded value.
function isRolesRelationship(relationship) {
return relationship.name === 'Roles';
}
class Domain extends Base {

@@ -212,16 +218,32 @@ constructor(warpworks, name, desc, recreate) {

authenticateUser(persistence, UserName, Password) {
// TODO: Not hard-code entity names.
return persistence.aggregate('Account', 'parentID', 'User', '_id', 'userInfo', { UserName, Password })
.then((users) => {
if (users && users.length === 1) {
const data = _.extend({}, users[0].userInfo[0], {
UserName
});
// TODO: What else to remove?
delete data.ReadAccess;
delete data.WriteAccess;
return data;
return users[0].userInfo[0];
}
throw new DomainError("Authentication failed.");
})
.then((user) => {
const userEntity = this.getEntityByName('User');
const relationships = userEntity.getRelationships().filter(isRolesRelationship);
return Promise.reduce(
relationships,
(memo, relationship) => relationship.getDocuments(persistence, user)
.then((roles) => memo.concat(roles)),
[]
)
.then((roles) => {
return _.extend({}, _.pick(user, ['_id', 'type', 'Name']), {
UserName,
Roles: roles.map((role) => ({
type: role.type,
Name: role.Name,
Description: role.Description,
id: role.id,
label: role.Name
}))
});
});
});

@@ -228,0 +250,0 @@ }

@@ -105,4 +105,8 @@ const Promise = require('bluebird');

return Promise.map(references,
(reference) => targetEntity.getInstance(persistence, reference.id));
return Promise.reduce(
this.getTargetReferences(instance),
(memo, reference) => targetEntity.getInstance(persistence, reference._id)
.then((targetInstance) => memo.concat(targetInstance)),
[]
);
}

@@ -109,0 +113,0 @@

{
"name": "@warp-works/core",
"version": "1.0.0-rc1",
"version": "1.0.0-rc2",
"description": "Core library for WarpWorks",

@@ -42,7 +42,7 @@ "main": "lib/index.js",

"eslint-plugin-import": "2.3.0",
"eslint-plugin-node": "4.2.2",
"eslint-plugin-node": "5.0.0",
"eslint-plugin-promise": "3.5.0",
"eslint-plugin-standard": "3.0.1",
"mocha": "3.4.2",
"nyc": "10.3.2"
"nyc": "11.0.2"
},

@@ -54,4 +54,4 @@ "dependencies": {

"lodash": "4.17.4",
"mongodb": "2.2.27"
"mongodb": "2.2.28"
}
}
# Releases
## 1.0.0-rc2 - 2017-06-04
- Fixed `domain.authenticateUser()` with new document structure.
## 1.0.0-rc1 - 2017-05-31

@@ -4,0 +8,0 @@

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