@flowerforce/flowerbase 1.2.1-beta.10 → 1.2.1-beta.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.
@@ -28,6 +28,7 @@ export declare const AUTH_CONFIG: {
28
28
  resetPasswordCollection: string;
29
29
  refreshTokensCollection: string;
30
30
  resetPasswordConfig: import("./auth/utils").Config;
31
+ localUserpassConfig: import("./auth/utils").Config;
31
32
  user_id_field: string;
32
33
  on_user_creation_function_name: string;
33
34
  providers: {
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAUpC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;iBAiBsB,eAAe,EAAE;;CAEjE,CAAA;AACD,eAAO,MAAM,WAAW,QAA8C,CAAA;AACtE,eAAO,MAAM,YAAY,QAA8B,CAAA;AACvD,eAAO,MAAM,OAAO,QAAgB,CAAA;AAGpC,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAWvB,CAAA;AAID,eAAO,MAAM,SAAS;;;CAGrB,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAUpC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;iBAiBsB,eAAe,EAAE;;CAEjE,CAAA;AACD,eAAO,MAAM,WAAW,QAA8C,CAAA;AACtE,eAAO,MAAM,YAAY,QAA8B,CAAA;AACvD,eAAO,MAAM,OAAO,QAAgB,CAAA;AAGpC,eAAO,MAAM,WAAW;;;;;;;;;;;;;;CAYvB,CAAA;AAID,eAAO,MAAM,SAAS;;;CAGrB,CAAA"}
package/dist/constants.js CHANGED
@@ -10,12 +10,12 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  }
11
11
  return t;
12
12
  };
13
- var _a, _b;
13
+ var _a, _b, _c;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.S3_CONFIG = exports.AUTH_CONFIG = exports.DB_NAME = exports.HTTPS_SCHEMA = exports.API_VERSION = exports.DEFAULT_CONFIG = void 0;
16
16
  const utils_1 = require("./auth/utils");
17
17
  const { database_name, collection_name = 'users', user_id_field = 'id', on_user_creation_function_name } = (0, utils_1.loadCustomUserData)();
18
- const _c = (0, utils_1.loadAuthConfig)(), { auth_collection = 'auth_users' } = _c, configuration = __rest(_c, ["auth_collection"]);
18
+ const _d = (0, utils_1.loadAuthConfig)(), { auth_collection = 'auth_users' } = _d, configuration = __rest(_d, ["auth_collection"]);
19
19
  exports.DEFAULT_CONFIG = {
20
20
  PORT: Number(process.env.PORT) || 3000,
21
21
  MONGODB_URL: process.env.MONGODB_URL || '',
@@ -46,10 +46,11 @@ exports.AUTH_CONFIG = {
46
46
  resetPasswordCollection: 'reset_password_requests',
47
47
  refreshTokensCollection: 'auth_refresh_tokens',
48
48
  resetPasswordConfig: (_a = configuration['local-userpass']) === null || _a === void 0 ? void 0 : _a.config,
49
+ localUserpassConfig: (_b = configuration['local-userpass']) === null || _b === void 0 ? void 0 : _b.config,
49
50
  user_id_field,
50
51
  on_user_creation_function_name,
51
52
  providers: {
52
- "custom-function": (_b = configuration['custom-function']) === null || _b === void 0 ? void 0 : _b.config
53
+ "custom-function": (_c = configuration['custom-function']) === null || _c === void 0 ? void 0 : _c.config
53
54
  }
54
55
  };
55
56
  exports.S3_CONFIG = {
@@ -1 +1 @@
1
- {"version":3,"file":"handleUserRegistration.d.ts","sourceRoot":"","sources":["../../src/shared/handleUserRegistration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAE9E;;;;;;GAMG;AACH,QAAA,MAAM,sBAAsB,EAAE,sBAmD7B,CAAA;AAED,eAAe,sBAAsB,CAAA"}
1
+ {"version":3,"file":"handleUserRegistration.d.ts","sourceRoot":"","sources":["../../src/shared/handleUserRegistration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAE9E;;;;;;GAMG;AACH,QAAA,MAAM,sBAAsB,EAAE,sBAoD7B,CAAA;AAED,eAAe,sBAAsB,CAAA"}
@@ -19,11 +19,13 @@ const crypto_1 = require("../utils/crypto");
19
19
  * @returns {Promise<InsertOneResult<Document>>} A promise resolving to the result of the insert operation.
20
20
  */
21
21
  const handleUserRegistration = (app, opt) => (_a) => __awaiter(void 0, [_a], void 0, function* ({ email, password }) {
22
+ var _b;
22
23
  const { run_as_system, skipUserCheck, provider } = opt !== null && opt !== void 0 ? opt : {};
23
24
  if (!run_as_system) {
24
25
  throw new Error('only run_as_system');
25
26
  }
26
27
  const { authCollection } = constants_1.AUTH_CONFIG;
28
+ const autoConfirm = ((_b = constants_1.AUTH_CONFIG.localUserpassConfig) === null || _b === void 0 ? void 0 : _b.autoConfirm) === true;
27
29
  const mongo = app === null || app === void 0 ? void 0 : app.mongo;
28
30
  const db = mongo.client.db(constants_1.DB_NAME);
29
31
  const hashedPassword = yield (0, crypto_1.hashPassword)(password);
@@ -34,7 +36,7 @@ const handleUserRegistration = (app, opt) => (_a) => __awaiter(void 0, [_a], voi
34
36
  const result = yield (db === null || db === void 0 ? void 0 : db.collection(authCollection).insertOne({
35
37
  email,
36
38
  password: hashedPassword,
37
- status: skipUserCheck ? 'confirmed' : 'pending',
39
+ status: skipUserCheck || autoConfirm ? 'confirmed' : 'pending',
38
40
  createdAt: new Date(),
39
41
  custom_data: {
40
42
  // TODO: aggiungere dati personalizzati alla registrazione
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowerforce/flowerbase",
3
- "version": "1.2.1-beta.10",
3
+ "version": "1.2.1-beta.11",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/constants.ts CHANGED
@@ -40,6 +40,7 @@ export const AUTH_CONFIG = {
40
40
  resetPasswordCollection: 'reset_password_requests',
41
41
  refreshTokensCollection: 'auth_refresh_tokens',
42
42
  resetPasswordConfig: configuration['local-userpass']?.config,
43
+ localUserpassConfig: configuration['local-userpass']?.config,
43
44
  user_id_field,
44
45
  on_user_creation_function_name,
45
46
  providers: {
@@ -17,6 +17,7 @@ const handleUserRegistration: HandleUserRegistration = (app, opt) => async ({ em
17
17
  }
18
18
 
19
19
  const { authCollection } = AUTH_CONFIG
20
+ const autoConfirm = AUTH_CONFIG.localUserpassConfig?.autoConfirm === true
20
21
  const mongo = app?.mongo
21
22
  const db = mongo.client.db(DB_NAME)
22
23
  const hashedPassword = await hashPassword(password)
@@ -29,7 +30,7 @@ const handleUserRegistration: HandleUserRegistration = (app, opt) => async ({ em
29
30
  const result = await db?.collection(authCollection!).insertOne({
30
31
  email,
31
32
  password: hashedPassword,
32
- status: skipUserCheck ? 'confirmed' : 'pending',
33
+ status: skipUserCheck || autoConfirm ? 'confirmed' : 'pending',
33
34
  createdAt: new Date(),
34
35
  custom_data: {
35
36
  // TODO: aggiungere dati personalizzati alla registrazione