scheduler-node-models 1.1.9 → 1.1.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scheduler-node-models",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "files": [
package/users/user.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { ObjectId } from "mongodb";
2
1
  /**
3
2
  * The user class and interface.
4
3
  */
@@ -7,7 +6,8 @@ import { ObjectId } from "mongodb";
7
6
  * its class object.
8
7
  */
9
8
  export interface IUser {
10
- _id?: ObjectId;
9
+ _id?: string;
10
+ id: string;
11
11
  emailAddress: string;
12
12
  password?: string;
13
13
  passwordExpires: Date;
@@ -37,7 +37,7 @@ export interface IUser {
37
37
  * password change, plus token expiration date/time the reset token expires)
38
38
  */
39
39
  export declare class User implements IUser {
40
- _id: ObjectId;
40
+ id: string;
41
41
  emailAddress: string;
42
42
  password?: string;
43
43
  passwordExpires: Date;
package/users/user.js CHANGED
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.User = void 0;
4
- const mongodb_1 = require("mongodb");
5
- const bcrypt_1 = require("bcrypt");
4
+ const bcrypt_ts_1 = require("bcrypt-ts");
6
5
  /**
7
6
  * This class represents a user and all the actions available to the user object.
8
7
  * The main class members are:
@@ -20,7 +19,7 @@ const bcrypt_1 = require("bcrypt");
20
19
  * password change, plus token expiration date/time the reset token expires)
21
20
  */
22
21
  class User {
23
- _id;
22
+ id;
24
23
  emailAddress;
25
24
  password;
26
25
  passwordExpires;
@@ -33,7 +32,10 @@ class User {
33
32
  resettokenexp;
34
33
  additionalEmails;
35
34
  constructor(user) {
36
- this._id = (user && user._id) ? user._id : new mongodb_1.ObjectId();
35
+ this.id = (user && user.id) ? user.id : '';
36
+ if (this.id === '') {
37
+ this.id = (user && user._id) ? user._id.toString() : '';
38
+ }
37
39
  this.emailAddress = (user) ? user.emailAddress : '';
38
40
  this.password = (user) ? user.password : undefined;
39
41
  this.passwordExpires = (user) ? new Date(user.passwordExpires) : new Date();
@@ -104,8 +106,8 @@ class User {
104
106
  * @param passwd The string value for the new password
105
107
  */
106
108
  setPassword(passwd) {
107
- const salt = (0, bcrypt_1.genSaltSync)(12);
108
- const result = (0, bcrypt_1.hashSync)(passwd, salt);
109
+ const salt = (0, bcrypt_ts_1.genSaltSync)(12);
110
+ const result = (0, bcrypt_ts_1.hashSync)(passwd, salt);
109
111
  this.password = result;
110
112
  this.passwordExpires = new Date();
111
113
  this.badAttempts = 0;
@@ -117,7 +119,7 @@ class User {
117
119
  * @throws An error if the account is locked or there is a mismatch with the password.
118
120
  */
119
121
  checkPassword(pwd) {
120
- if (this.password && (0, bcrypt_1.compareSync)(pwd, this.password)) {
122
+ if (this.password && (0, bcrypt_ts_1.compareSync)(pwd, this.password)) {
121
123
  if (this.badAttempts > 2) {
122
124
  throw new Error("Account Locked");
123
125
  }
package/users/web.d.ts CHANGED
@@ -20,3 +20,12 @@ export interface AddUserRequest {
20
20
  application: string;
21
21
  permissions?: string[];
22
22
  }
23
+ /**
24
+ * This interface will be used to update a user with a call from the client to the
25
+ * api server. All fields would be required.
26
+ */
27
+ export interface UpdateUserRequest {
28
+ id: string;
29
+ field: string;
30
+ value: string;
31
+ }