quidproquo-actionprocessor-awslambda 0.0.261 → 0.0.262
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.
|
@@ -15,12 +15,17 @@ const quidproquo_core_1 = require("quidproquo-core");
|
|
|
15
15
|
const awsNamingUtils_1 = require("../../../awsNamingUtils");
|
|
16
16
|
const getExportedValue_1 = require("../../../logic/cloudformation/getExportedValue");
|
|
17
17
|
const createUser_1 = require("../../../logic/cognito/createUser");
|
|
18
|
+
const resolveUsernameByPreferredUsername_1 = require("../../../logic/cognito/resolveUsernameByPreferredUsername");
|
|
18
19
|
const getProcessCreateUser = (qpqConfig) => {
|
|
19
20
|
return (payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
21
|
const region = quidproquo_config_aws_1.qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
21
22
|
const userPoolId = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameUserPoolIdFromConfig)(payload.userDirectoryName, qpqConfig), region);
|
|
22
23
|
const userPoolClientId = yield (0, getExportedValue_1.getExportedValue)((0, awsNamingUtils_1.getCFExportNameUserPoolClientIdFromConfig)(payload.userDirectoryName, qpqConfig), region);
|
|
23
|
-
const
|
|
24
|
+
const resolvedUsername = yield (0, resolveUsernameByPreferredUsername_1.resolveUsernameByPreferredUsername)(userPoolId, region, payload.createUserRequest.email);
|
|
25
|
+
if (resolvedUsername !== payload.createUserRequest.email) {
|
|
26
|
+
return (0, quidproquo_core_1.actionResultError)(quidproquo_core_1.ErrorTypeEnum.Conflict, 'An account with this email already exists');
|
|
27
|
+
}
|
|
28
|
+
const authResponse = yield (0, createUser_1.createUser)(userPoolId, region, userPoolClientId, payload.createUserRequest);
|
|
24
29
|
return (0, quidproquo_core_1.actionResult)(authResponse);
|
|
25
30
|
});
|
|
26
31
|
};
|
package/lib/esm/getActionProcessor/core/userDirectory/getUserDirectoryCreateUserActionProcessor.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { qpqConfigAwsUtils } from 'quidproquo-config-aws';
|
|
2
|
-
import { actionResult, UserDirectoryActionType, } from 'quidproquo-core';
|
|
2
|
+
import { actionResult, actionResultError, ErrorTypeEnum, UserDirectoryActionType, } from 'quidproquo-core';
|
|
3
3
|
import { getCFExportNameUserPoolClientIdFromConfig, getCFExportNameUserPoolIdFromConfig } from '../../../awsNamingUtils';
|
|
4
4
|
import { getExportedValue } from '../../../logic/cloudformation/getExportedValue';
|
|
5
5
|
import { createUser } from '../../../logic/cognito/createUser';
|
|
6
|
+
import { resolveUsernameByPreferredUsername } from '../../../logic/cognito/resolveUsernameByPreferredUsername';
|
|
6
7
|
const getProcessCreateUser = (qpqConfig) => {
|
|
7
8
|
return async (payload) => {
|
|
8
9
|
const region = qpqConfigAwsUtils.getApplicationModuleDeployRegion(qpqConfig);
|
|
9
10
|
const userPoolId = await getExportedValue(getCFExportNameUserPoolIdFromConfig(payload.userDirectoryName, qpqConfig), region);
|
|
10
11
|
const userPoolClientId = await getExportedValue(getCFExportNameUserPoolClientIdFromConfig(payload.userDirectoryName, qpqConfig), region);
|
|
11
|
-
const
|
|
12
|
+
const resolvedUsername = await resolveUsernameByPreferredUsername(userPoolId, region, payload.createUserRequest.email);
|
|
13
|
+
if (resolvedUsername !== payload.createUserRequest.email) {
|
|
14
|
+
return actionResultError(ErrorTypeEnum.Conflict, 'An account with this email already exists');
|
|
15
|
+
}
|
|
16
|
+
const authResponse = await createUser(userPoolId, region, userPoolClientId, payload.createUserRequest);
|
|
12
17
|
return actionResult(authResponse);
|
|
13
18
|
};
|
|
14
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quidproquo-actionprocessor-awslambda",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.262",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/esm/index.js",
|
|
@@ -57,16 +57,16 @@
|
|
|
57
57
|
"lodash": "^4.17.21",
|
|
58
58
|
"node-cache": "^5.1.2",
|
|
59
59
|
"node-match-path": "^0.6.3",
|
|
60
|
-
"quidproquo-config-aws": "0.0.
|
|
61
|
-
"quidproquo-core": "0.0.
|
|
62
|
-
"quidproquo-webserver": "0.0.
|
|
60
|
+
"quidproquo-config-aws": "0.0.262",
|
|
61
|
+
"quidproquo-core": "0.0.262",
|
|
62
|
+
"quidproquo-webserver": "0.0.262"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/busboy": "^1.5.0",
|
|
66
66
|
"@types/jsonwebtoken": "^9.0.2",
|
|
67
67
|
"@types/lodash": "^4.14.194",
|
|
68
68
|
"@types/node": "^22.13.13",
|
|
69
|
-
"quidproquo-tsconfig": "0.0.
|
|
69
|
+
"quidproquo-tsconfig": "0.0.262",
|
|
70
70
|
"typescript": "^5.8.2"
|
|
71
71
|
}
|
|
72
72
|
}
|