@memberjunction/codegen-lib 0.9.38 → 0.9.39
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/dist/createNewUser.js
CHANGED
|
@@ -4,18 +4,19 @@ exports.createNewUser = void 0;
|
|
|
4
4
|
const core_1 = require("@memberjunction/core");
|
|
5
5
|
const config_1 = require("./config");
|
|
6
6
|
const sqlserver_dataprovider_1 = require("@memberjunction/sqlserver-dataprovider");
|
|
7
|
+
const logging_1 = require("./logging");
|
|
7
8
|
async function createNewUser(newUserSetup) {
|
|
8
9
|
try {
|
|
9
10
|
const matches = sqlserver_dataprovider_1.UserCache.Users.find(u => u?.Type?.trim().toLowerCase() === 'owner');
|
|
10
11
|
const currentUser = matches ? matches : sqlserver_dataprovider_1.UserCache.Users[0]; // if we don't find an Owner, use the first user in the cache
|
|
11
12
|
if (!currentUser) {
|
|
12
|
-
|
|
13
|
+
(0, logging_1.logError)("No existing users found in the database, cannot create a new user");
|
|
13
14
|
return false;
|
|
14
15
|
}
|
|
15
16
|
if (newUserSetup) {
|
|
16
17
|
if (newUserSetup.IsComplete === false || newUserSetup.IsComplete === undefined || newUserSetup.IsComplete === null) {
|
|
17
18
|
if (newUserSetup.Email && newUserSetup.Email.length > 0) {
|
|
18
|
-
|
|
19
|
+
(0, logging_1.logStatus)("Attempting to create new user: " + newUserSetup.Email);
|
|
19
20
|
const md = new core_1.Metadata();
|
|
20
21
|
const user = await md.GetEntityObject('Users', currentUser);
|
|
21
22
|
user.NewRecord();
|
|
@@ -47,20 +48,20 @@ async function createNewUser(newUserSetup) {
|
|
|
47
48
|
}
|
|
48
49
|
else {
|
|
49
50
|
// saving the user failed, so we don't atempt to create User Roles, throw error
|
|
50
|
-
|
|
51
|
+
(0, logging_1.logError)("Failed to save user: " + newUserSetup.Email);
|
|
51
52
|
return false;
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
else {
|
|
57
|
-
|
|
58
|
+
(0, logging_1.logError)("No NewUserSetup object provided, createNewUser() shouldn't be called without a valid object");
|
|
58
59
|
return false;
|
|
59
60
|
}
|
|
60
61
|
return true;
|
|
61
62
|
}
|
|
62
63
|
catch (err) {
|
|
63
|
-
|
|
64
|
+
(0, logging_1.logError)("Error attemping to create a new user", err);
|
|
64
65
|
return false;
|
|
65
66
|
}
|
|
66
67
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewUser.js","sourceRoot":"","sources":["../src/createNewUser.ts"],"names":[],"mappings":";;;AAAA,+CAA0D;AAC1D,qCAAkE;AAElE,mFAAmE;
|
|
1
|
+
{"version":3,"file":"createNewUser.js","sourceRoot":"","sources":["../src/createNewUser.ts"],"names":[],"mappings":";;;AAAA,+CAA0D;AAC1D,qCAAkE;AAElE,mFAAmE;AACnE,uCAAgD;AAEzC,KAAK,UAAU,aAAa,CAAC,YAA0B;IAC1D,IAAI;QACA,MAAM,OAAO,GAAa,kCAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,KAAI,OAAO,CAAC,CAAC;QAC9F,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,kCAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,6DAA6D;QAEzH,IAAI,CAAC,WAAW,EAAE;YACd,IAAA,kBAAQ,EAAC,mEAAmE,CAAC,CAAC;YAC9E,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,YAAY,EAAE;YACd,IAAI,YAAY,CAAC,UAAU,KAAK,KAAK,IAAI,YAAY,CAAC,UAAU,KAAK,SAAS,IAAI,YAAY,CAAC,UAAU,KAAK,IAAI,EAAE;gBAChH,IAAI,YAAY,CAAC,KAAK,IAAI,YAAY,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;oBACrD,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