@resolveio/server-lib 4.0.13 → 4.0.14-newrole
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/collections/user.collection.js +39 -32
- package/fixtures/init.js +1 -1
- package/http/auth.js +23 -6
- package/package.json +1 -1
|
@@ -21,13 +21,6 @@ var schema = {
|
|
|
21
21
|
type: Date,
|
|
22
22
|
optional: true
|
|
23
23
|
},
|
|
24
|
-
readonly: {
|
|
25
|
-
type: Boolean,
|
|
26
|
-
optional: true
|
|
27
|
-
},
|
|
28
|
-
active: {
|
|
29
|
-
type: Boolean
|
|
30
|
-
},
|
|
31
24
|
attempts: {
|
|
32
25
|
type: Number,
|
|
33
26
|
optional: true
|
|
@@ -64,53 +57,67 @@ var schema = {
|
|
|
64
57
|
type: String
|
|
65
58
|
},
|
|
66
59
|
roles: {
|
|
60
|
+
type: Object
|
|
61
|
+
},
|
|
62
|
+
'roles.super_admin': {
|
|
63
|
+
type: Boolean
|
|
64
|
+
},
|
|
65
|
+
'roles.approvals': {
|
|
67
66
|
type: Array
|
|
68
67
|
},
|
|
69
|
-
'roles.$': {
|
|
68
|
+
'roles.approvals.$': {
|
|
69
|
+
type: Object
|
|
70
|
+
},
|
|
71
|
+
'roles.approvals.$.name': {
|
|
70
72
|
type: String
|
|
71
73
|
},
|
|
72
|
-
|
|
73
|
-
type: String
|
|
74
|
-
optional: true
|
|
74
|
+
'roles.approvals.$.type': {
|
|
75
|
+
type: String
|
|
75
76
|
},
|
|
76
|
-
|
|
77
|
-
type:
|
|
78
|
-
blackbox: true,
|
|
79
|
-
optional: true
|
|
77
|
+
'roles.approvals.$.accounting_code': {
|
|
78
|
+
type: String
|
|
80
79
|
},
|
|
81
|
-
|
|
82
|
-
type: Array
|
|
83
|
-
optional: true
|
|
80
|
+
'roles.groups': {
|
|
81
|
+
type: Array
|
|
84
82
|
},
|
|
85
|
-
'
|
|
83
|
+
'roles.groups.$': {
|
|
86
84
|
type: Object
|
|
87
85
|
},
|
|
88
|
-
'
|
|
86
|
+
'roles.groups.$.name': {
|
|
89
87
|
type: String
|
|
90
88
|
},
|
|
91
|
-
'
|
|
92
|
-
type:
|
|
89
|
+
'roles.groups.$.views': {
|
|
90
|
+
type: Array
|
|
93
91
|
},
|
|
94
|
-
'
|
|
92
|
+
'roles.groups.$.views.$': {
|
|
95
93
|
type: String
|
|
96
94
|
},
|
|
97
|
-
'
|
|
98
|
-
type: String
|
|
95
|
+
'roles.groups.$.yard': {
|
|
96
|
+
type: String,
|
|
97
|
+
optional: true
|
|
98
|
+
},
|
|
99
|
+
'roles.notifications': {
|
|
100
|
+
type: Array
|
|
99
101
|
},
|
|
100
|
-
'
|
|
102
|
+
'roles.notifications.$': {
|
|
101
103
|
type: String
|
|
102
104
|
},
|
|
103
|
-
'
|
|
104
|
-
type:
|
|
105
|
+
'roles.miscs': {
|
|
106
|
+
type: Array
|
|
105
107
|
},
|
|
106
|
-
'
|
|
107
|
-
type:
|
|
108
|
-
optional: true
|
|
108
|
+
'roles.miscs.$': {
|
|
109
|
+
type: String
|
|
109
110
|
},
|
|
110
|
-
|
|
111
|
+
active: Boolean,
|
|
112
|
+
phonenumber: {
|
|
111
113
|
type: String,
|
|
112
114
|
optional: true
|
|
113
115
|
},
|
|
116
|
+
other: {
|
|
117
|
+
type: Object,
|
|
118
|
+
optional: true,
|
|
119
|
+
blackbox: true
|
|
120
|
+
},
|
|
114
121
|
customers: {
|
|
115
122
|
type: Array,
|
|
116
123
|
optional: true,
|
package/fixtures/init.js
CHANGED
|
@@ -37,8 +37,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
var app_version_collection_1 = require("../collections/app-version.collection");
|
|
39
39
|
var logged_in_users_collection_1 = require("../collections/logged-in-users.collection");
|
|
40
|
-
var active_subscription_collection_1 = require("../collections/active-subscription.collection");
|
|
41
40
|
var mongoose_1 = require("mongoose");
|
|
41
|
+
var active_subscription_collection_1 = require("../collections/active-subscription.collection");
|
|
42
42
|
function loadServerInit() {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function () {
|
|
44
44
|
var appVersion;
|
package/http/auth.js
CHANGED
|
@@ -43,7 +43,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
43
43
|
var _this = this;
|
|
44
44
|
// Login via HTTP, return refresh token if authenticated
|
|
45
45
|
app.post('/login', function (request, response) { return __awaiter(_this, void 0, void 0, function () {
|
|
46
|
-
var user_1, username, resAuth_1, emailData_1;
|
|
46
|
+
var user_1, username, resAuth_1, emailData_1, emailData_2;
|
|
47
47
|
return __generator(this, function (_a) {
|
|
48
48
|
switch (_a.label) {
|
|
49
49
|
case 0:
|
|
@@ -88,6 +88,27 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
88
88
|
}, function (errEmail) { return console.log(errEmail); });
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
+
else if (resAuth_1.error === 'NoSaltValueStoredError') {
|
|
92
|
+
response.send(JSON.stringify({
|
|
93
|
+
error: true,
|
|
94
|
+
result: 'A password reset link has been sent to your email, please reset your password.'
|
|
95
|
+
}));
|
|
96
|
+
user_1.services.forgot_password = jwt.sign({ id_user: user_1._id }, serverConfig['JWT_SECRET']);
|
|
97
|
+
emailData_2 = {
|
|
98
|
+
userToChangePassword: user_1.fullname,
|
|
99
|
+
userWhoResetPassword: __1.ResolveIOServer.getClientName() + ' System',
|
|
100
|
+
url: serverConfig['ROOT_URL'] + '/forgot-password?' + encodeURIComponent(serverConfig['SERVER_URL']) + '&' + user_1.services.forgot_password
|
|
101
|
+
};
|
|
102
|
+
user_collection_1.Users.updateOne({ _id: user_1._id }, { $set: { services: user_1.services } }).exec(function (errUp, resUp) {
|
|
103
|
+
mainServer.getMethodManager().readFile('email-templates/forgot-password.html').then(function (html) {
|
|
104
|
+
var template = handlebars.compile(html);
|
|
105
|
+
handlebars.registerHelper('equals', function (a, b) {
|
|
106
|
+
return a === b;
|
|
107
|
+
});
|
|
108
|
+
mainServer.getMethodManager().sendEmail(user_1.email, 'ResolveIO (' + __1.ResolveIOServer.getClientName() + ') - Forgot Password', '', template(emailData_2));
|
|
109
|
+
}, function (errEmail) { return console.log(errEmail); });
|
|
110
|
+
});
|
|
111
|
+
}
|
|
91
112
|
else {
|
|
92
113
|
response.send(JSON.stringify({
|
|
93
114
|
error: true,
|
|
@@ -137,7 +158,6 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
137
158
|
if (user) {
|
|
138
159
|
if (user.active) {
|
|
139
160
|
user.resetAttempts(function (err, res) {
|
|
140
|
-
user.save();
|
|
141
161
|
response.send(JSON.stringify({
|
|
142
162
|
error: false,
|
|
143
163
|
result: {
|
|
@@ -184,7 +204,6 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
184
204
|
if (user) {
|
|
185
205
|
if (user.active) {
|
|
186
206
|
user.resetAttempts(function (err, res) {
|
|
187
|
-
user.save();
|
|
188
207
|
response.send(JSON.stringify({
|
|
189
208
|
error: false,
|
|
190
209
|
result: {
|
|
@@ -428,9 +447,7 @@ function setupAuthRoutes(mainServer, app, serverConfig) {
|
|
|
428
447
|
user.setPassword(request.body.password, function (errSet, resSet) {
|
|
429
448
|
if (resSet) {
|
|
430
449
|
user.services.forgot_password = '';
|
|
431
|
-
user.resetAttempts(
|
|
432
|
-
user.save();
|
|
433
|
-
});
|
|
450
|
+
user.resetAttempts();
|
|
434
451
|
response.send(JSON.stringify({
|
|
435
452
|
error: false,
|
|
436
453
|
result: true
|