@burgan-tech/morph-idm-runtime 0.0.1 → 0.0.2
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/burgan-tech-morph-idm-runtime-0.0.2.tgz +0 -0
- package/morph-idm/Schemas/{user → person}/person-master-1.0.0.json +1 -1
- package/morph-idm/Schemas/token/token-start-1.0.0.json +6 -19
- package/morph-idm/Schemas/user/user-master-1.0.0.json +46 -1
- package/morph-idm/Schemas/user-login/retry-login-1.0.0.json +39 -0
- package/morph-idm/Tasks/call-device-start-1.0.0.json +1 -1
- package/morph-idm/Tasks/call-device-update-1.0.0.json +1 -1
- package/morph-idm/Tasks/consent/consent-auto-select-script.json +16 -0
- package/morph-idm/Tasks/device/search-device-task.json +22 -0
- package/morph-idm/Tasks/get-device-1.0.0.json +1 -1
- package/morph-idm/Tasks/person/get-person-by-task.json +19 -0
- package/morph-idm/Tasks/person/person-update-direct-transition.json +23 -0
- package/morph-idm/Tasks/token/token-create-jwt.json +0 -1
- package/morph-idm/Tasks/token/token-redeem-trigger.json +22 -0
- package/morph-idm/Tasks/token/user-login-get-as-filterable.json +22 -0
- package/morph-idm/Tasks/user/evaluate-failed-login-script.json +18 -0
- package/morph-idm/Tasks/user/get-phone-from-person-task.json +20 -0
- package/morph-idm/Tasks/user/otp-code-generator.json +15 -0
- package/morph-idm/Tasks/user/send-otp-sms-task.json +26 -0
- package/morph-idm/Tasks/user/send-push-task.json +4 -1
- package/morph-idm/Tasks/user/user-update-password-fail-count.json +24 -0
- package/morph-idm/Tasks/user-login/auth-code-generator.json +17 -0
- package/morph-idm/Tasks/user-login/increment-local-fail-count.json +17 -0
- package/morph-idm/Tasks/user-login/password-verify.json +26 -0
- package/morph-idm/TestCases/test-123/.httpyac.json +15 -0
- package/morph-idm/TestCases/test-123/01-person.http +95 -0
- package/morph-idm/TestCases/test-123/02-user.http +83 -0
- package/morph-idm/TestCases/test-123/03-scope.http +65 -0
- package/morph-idm/TestCases/test-123/04-consent.http +66 -0
- package/morph-idm/TestCases/test-123/05-device.http +86 -0
- package/morph-idm/TestCases/test-123/06-user-login.http +206 -0
- package/morph-idm/TestCases/test-123/README.md +112 -0
- package/morph-idm/TestCases/test-123/cleanup.js +49 -0
- package/morph-idm/TestCases/test-123/cleanup.sh +20 -0
- package/morph-idm/TestCases/test-123/cleanup.sql +45 -0
- package/morph-idm/TestCases/test-123/http-client.env.json +13 -0
- package/morph-idm/TestCases/test-123/run-setup.sh +42 -0
- package/morph-idm/TestCases/test-auto-consent/.httpyac.json +14 -0
- package/morph-idm/TestCases/test-auto-consent/01-person.http +72 -0
- package/morph-idm/TestCases/test-auto-consent/02-user.http +74 -0
- package/morph-idm/TestCases/test-auto-consent/03-scope.http +66 -0
- package/morph-idm/TestCases/test-auto-consent/04-device.http +56 -0
- package/morph-idm/TestCases/test-auto-consent/05-user-login.http +132 -0
- package/morph-idm/TestCases/test-auto-consent/README.md +36 -0
- package/morph-idm/TestCases/test-auto-consent/cleanup.js +47 -0
- package/morph-idm/TestCases/test-auto-consent/run-setup.sh +50 -0
- package/morph-idm/TestCases/test-multiple-consent/.httpyac.json +17 -0
- package/morph-idm/TestCases/test-multiple-consent/01-person.http +103 -0
- package/morph-idm/TestCases/test-multiple-consent/02-user.http +83 -0
- package/morph-idm/TestCases/test-multiple-consent/03-scope-2.http +66 -0
- package/morph-idm/TestCases/test-multiple-consent/03-scope.http +66 -0
- package/morph-idm/TestCases/test-multiple-consent/04-consent-1.http +67 -0
- package/morph-idm/TestCases/test-multiple-consent/04-consent-2.http +66 -0
- package/morph-idm/TestCases/test-multiple-consent/05-device.http +87 -0
- package/morph-idm/TestCases/test-multiple-consent/06-user-login.http +183 -0
- package/morph-idm/TestCases/test-multiple-consent/README.md +37 -0
- package/morph-idm/TestCases/test-multiple-consent/cleanup.js +46 -0
- package/morph-idm/TestCases/test-multiple-consent/cleanup.sh +20 -0
- package/morph-idm/TestCases/test-multiple-consent/run-setup.sh +53 -0
- package/morph-idm/Views/user-login/push-waiting.json +28 -0
- package/morph-idm/Views/user-login/start.json +28 -0
- package/morph-idm/Workflows/client/client-1.0.0.json +1 -1
- package/morph-idm/Workflows/client/execute/client.http +1 -1
- package/morph-idm/Workflows/client/src/PasswordGeneratorMapping.csx +0 -1
- package/morph-idm/Workflows/consent-selection/consent-selection-1.0.0.json +37 -6
- package/morph-idm/Workflows/consent-selection/execute/multi-consent-selection.http +209 -0
- package/morph-idm/Workflows/consent-selection/src/ConsentSelectedMapping.csx +18 -22
- package/morph-idm/Workflows/consent-selection/src/CreateAutoConsentMapping.csx +45 -45
- package/morph-idm/Workflows/consent-selection/src/MultipleConsentsRule.csx +12 -8
- package/morph-idm/Workflows/consent-selection/src/NoConsentEligibleRule.csx +6 -22
- package/morph-idm/Workflows/consent-selection/src/SingleConsentAutoSelectMapping.csx +63 -0
- package/morph-idm/Workflows/consent-selection/src/SingleConsentRule.csx +11 -22
- package/morph-idm/Workflows/device/execute/device-ios.http +0 -6
- package/morph-idm/Workflows/device/execute/search.http +32 -0
- package/morph-idm/Workflows/person/execute/person-123.http +191 -0
- package/morph-idm/Workflows/person/execute/person.http +196 -0
- package/morph-idm/Workflows/{user → person}/person-1.0.0.json +24 -1
- package/morph-idm/Workflows/token/execute/token.http +14 -3
- package/morph-idm/Workflows/token/password-subflow.json +1 -1
- package/morph-idm/Workflows/token/src/AuthCodeRedeemMapping.csx +114 -0
- package/morph-idm/Workflows/token/src/AuthCodeValidationRule.csx +27 -0
- package/morph-idm/Workflows/token/src/CreateRsaJwtMapping.csx +28 -16
- package/morph-idm/Workflows/token/src/StatusSuccessRule.csx +27 -0
- package/morph-idm/Workflows/token/src/TokenCreatedRule.csx +32 -0
- package/morph-idm/Workflows/token/src/UserLoginGetAsFilterableMapping.csx +204 -0
- package/morph-idm/Workflows/token/token-1.0.0.json +109 -41
- package/morph-idm/Workflows/user/execute/create-user-1234567890.http +16 -4
- package/morph-idm/Workflows/user/execute/create-user-migration.http +179 -0
- package/morph-idm/Workflows/user/execute/create-user-person-password.http +78 -32
- package/morph-idm/Workflows/user/src/EvaluateFailedLoginMapping.csx +75 -0
- package/morph-idm/Workflows/user/src/FailCountMaxRule.csx +33 -0
- package/morph-idm/Workflows/user/src/GetPhoneFromPersonMapping.csx +139 -0
- package/morph-idm/Workflows/user/src/HasPasswordsRule.csx +43 -0
- package/morph-idm/Workflows/user/src/OtpSentSuccessRule.csx +46 -0
- package/morph-idm/Workflows/user/src/PasswordGeneratedSuccessRule.csx +73 -0
- package/morph-idm/Workflows/user/src/PhoneFetchedSuccessRule.csx +35 -0
- package/morph-idm/Workflows/user/src/ResetPasswordFailCountMapping.csx +88 -0
- package/morph-idm/Workflows/user/src/SendOtpSmsMapping.csx +356 -0
- package/morph-idm/Workflows/user/src/UserPasswordGeneratorMapping.csx +33 -6
- package/morph-idm/Workflows/user/user-1.0.0.json +365 -5
- package/morph-idm/Workflows/{user → user-login}/execute/user-login.http +155 -32
- package/morph-idm/Workflows/user-login/src/AuthCodeGeneratorMapping.csx +44 -0
- package/morph-idm/Workflows/{user/src/GetClientMapping.csx → user-login/src/ClientGetMapping.csx} +6 -4
- package/morph-idm/Workflows/{user/src/TriggerConsentSelectionAsSubFlowMapping.csx → user-login/src/ConsentSelectionSubFlowMapping.csx} +19 -20
- package/morph-idm/Workflows/user-login/src/DeviceSearchMapping.csx +120 -0
- package/morph-idm/Workflows/{user → user-login}/src/GrantValidationRule.csx +5 -1
- package/morph-idm/Workflows/user-login/src/HasFailCountRule.csx +32 -0
- package/morph-idm/Workflows/user-login/src/MaxRetriesReachedRule.csx +32 -0
- package/morph-idm/Workflows/user-login/src/NoSecurityImageRule.csx +33 -0
- package/morph-idm/Workflows/user-login/src/NoSecurityQuestionRule.csx +65 -0
- package/morph-idm/Workflows/user-login/src/OtpCodeGenerateMapping.csx +37 -0
- package/morph-idm/Workflows/{user/src/SendOtpMapping.csx → user-login/src/OtpSendMapping.csx} +13 -7
- package/morph-idm/Workflows/user-login/src/OtpVerifiedRule.csx +35 -0
- package/morph-idm/Workflows/user-login/src/PasswordFailCountResetMapping.csx +77 -0
- package/morph-idm/Workflows/user-login/src/PasswordFailCountUpdateMapping.csx +80 -0
- package/morph-idm/Workflows/user-login/src/PasswordVerifyMapping.csx +169 -0
- package/morph-idm/Workflows/user-login/src/PersonFetchedRule.csx +32 -0
- package/morph-idm/Workflows/user-login/src/PersonGetMapping.csx +61 -0
- package/morph-idm/Workflows/user-login/src/PersonUpdateMapping.csx +105 -0
- package/morph-idm/Workflows/user-login/src/PersonUpdatedRule.csx +32 -0
- package/morph-idm/Workflows/user-login/src/PushVerifiedRule.csx +31 -0
- package/morph-idm/Workflows/{user/src/GetScopesByUserMapping.csx → user-login/src/ScopesByUserGetMapping.csx} +17 -17
- package/morph-idm/Workflows/user-login/src/TokenGenerationSuccessRule.csx +33 -0
- package/morph-idm/Workflows/{user/src/TriggerTokenWorkflowAsSubFlowMapping.csx → user-login/src/TokenSubFlowMapping.csx} +7 -13
- package/morph-idm/Workflows/user-login/src/UserFoundRule.csx +19 -0
- package/morph-idm/Workflows/{user/src/GetUserMapping.csx → user-login/src/UserGetMapping.csx} +5 -3
- package/morph-idm/Workflows/user-login/src/UserStatusActiveRule.csx +34 -0
- package/morph-idm/Workflows/user-login/src/UserValidHasFailCountRule.csx +39 -0
- package/morph-idm/Workflows/user-login/src/UserValidNoFailCountRule.csx +39 -0
- package/morph-idm/Workflows/user-login/user-login.1.0.0.json +1827 -0
- package/package.json +1 -1
- package/vnext.config.json +3 -3
- package/burgan-tech-morph-idm-runtime-0.0.1.tgz +0 -0
- package/morph-idm/Workflows/user/src/ApproveRule.csx +0 -16
- package/morph-idm/Workflows/user/src/AutoConsentCreatedRule.csx +0 -20
- package/morph-idm/Workflows/user/src/AutoConsentRequiredRule.csx +0 -77
- package/morph-idm/Workflows/user/src/CheckDeviceByUserReferenceMapping.csx +0 -66
- package/morph-idm/Workflows/user/src/ClientValidationFailRule.csx +0 -28
- package/morph-idm/Workflows/user/src/ConsentValidationRule.csx +0 -36
- package/morph-idm/Workflows/user/src/CreateAutoConsentMapping.csx +0 -171
- package/morph-idm/Workflows/user/src/DeviceFoundForLoginRule.csx +0 -32
- package/morph-idm/Workflows/user/src/DeviceNotFoundForLoginRule.csx +0 -31
- package/morph-idm/Workflows/user/src/GetConsentMapping.csx +0 -27
- package/morph-idm/Workflows/user/src/GetDeviceMapping.csx +0 -52
- package/morph-idm/Workflows/user/src/GetScopeMapping.csx +0 -139
- package/morph-idm/Workflows/user/src/GrantValidationFailRule.csx +0 -48
- package/morph-idm/Workflows/user/src/OtpVerifiedRule.csx +0 -31
- package/morph-idm/Workflows/user/src/PushVerifiedRule.csx +0 -31
- package/morph-idm/Workflows/user/src/RejectRule.csx +0 -16
- package/morph-idm/Workflows/user/src/ScopeValidationFailRule.csx +0 -67
- package/morph-idm/Workflows/user/src/ScopeValidationRule.csx +0 -67
- package/morph-idm/Workflows/user/src/SendPushMapping.csx +0 -90
- package/morph-idm/Workflows/user/src/TokenGenerationSuccessRule.csx +0 -28
- package/morph-idm/Workflows/user/src/UserValidationFailRule.csx +0 -36
- package/morph-idm/Workflows/user/src/VerifyOtpMapping.csx +0 -65
- package/morph-idm/Workflows/user/src/VerifyPushMapping.csx +0 -65
- package/morph-idm/Workflows/user/user-login.1.0.0.json +0 -1144
- /package/morph-idm/Workflows/{user → person}/person-cdc-worker.1.0.0.json +0 -0
- /package/morph-idm/Workflows/{user → person}/person-upsert-1.0.0.json +0 -0
- /package/morph-idm/Workflows/scope/execute/{scope-individual.http → scope-individual-1234567890-1234567890.http} +0 -0
- /package/morph-idm/Workflows/{user → user-login}/execute/README-LOGIN.md +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/ClientValidationRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/ConsentSelectedRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/IsIbWebClientWithDeviceRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/NonIbWebClientWithDeviceRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/OtpSentRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/PushSentRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/ScopeFetchedRule.csx +0 -0
- /package/morph-idm/Workflows/{user → user-login}/src/UserValidationRule.csx +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
using System.Threading.Tasks;
|
|
2
|
+
using BBT.Workflow.Scripting;
|
|
3
|
+
using BBT.Workflow.Scripting.Functions;
|
|
4
|
+
|
|
5
|
+
public class OtpSentSuccessRule : ScriptBase, IConditionMapping
|
|
6
|
+
{
|
|
7
|
+
public async Task<bool> Handler(ScriptContext context)
|
|
8
|
+
{
|
|
9
|
+
if (!HasProperty(context.Instance?.Data, "smsDelivery"))
|
|
10
|
+
{
|
|
11
|
+
LogWarning("OtpSentSuccessRule: smsDelivery not found");
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
var smsData = context.Instance?.Data?.smsDelivery;
|
|
16
|
+
|
|
17
|
+
if (smsData == null)
|
|
18
|
+
{
|
|
19
|
+
LogWarning("OtpSentSuccessRule: smsDelivery is null");
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Check success property
|
|
24
|
+
if (!HasProperty(smsData, "success"))
|
|
25
|
+
{
|
|
26
|
+
LogWarning("OtpSentSuccessRule: success property not found");
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
bool isSuccess = smsData.success == true;
|
|
31
|
+
|
|
32
|
+
if (isSuccess)
|
|
33
|
+
{
|
|
34
|
+
LogInformation($"OtpSentSuccessRule: SMS sent successfully");
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
else
|
|
38
|
+
{
|
|
39
|
+
var errorCode = HasProperty(smsData, "errorCode") ? smsData.errorCode?.ToString() : "unknown";
|
|
40
|
+
LogWarning($"OtpSentSuccessRule: SMS delivery failed - errorCode: {errorCode}");
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
using System.Threading.Tasks;
|
|
2
|
+
using BBT.Workflow.Scripting;
|
|
3
|
+
using BBT.Workflow.Scripting.Functions;
|
|
4
|
+
|
|
5
|
+
public class PasswordGeneratedSuccessRule : ScriptBase, IConditionMapping
|
|
6
|
+
{
|
|
7
|
+
public async Task<bool> Handler(ScriptContext context)
|
|
8
|
+
{
|
|
9
|
+
// Check if passwords array exists
|
|
10
|
+
if (!HasProperty(context.Instance?.Data, "passwords"))
|
|
11
|
+
{
|
|
12
|
+
LogWarning("PasswordGeneratedSuccessRule: passwords array not found");
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
var passwords = context.Instance?.Data?.passwords;
|
|
17
|
+
|
|
18
|
+
if (passwords == null)
|
|
19
|
+
{
|
|
20
|
+
LogWarning("PasswordGeneratedSuccessRule: passwords is null");
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Check if it's an array with at least one item
|
|
25
|
+
if (passwords is not IEnumerable<dynamic>)
|
|
26
|
+
{
|
|
27
|
+
LogWarning("PasswordGeneratedSuccessRule: passwords is not an array");
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var passwordList = ((IEnumerable<dynamic>)passwords).ToList();
|
|
32
|
+
|
|
33
|
+
if (passwordList.Count == 0)
|
|
34
|
+
{
|
|
35
|
+
LogWarning("PasswordGeneratedSuccessRule: passwords array is empty");
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Check if latest password has required fields
|
|
40
|
+
var latestPassword = passwordList.LastOrDefault();
|
|
41
|
+
if (latestPassword == null)
|
|
42
|
+
{
|
|
43
|
+
LogWarning("PasswordGeneratedSuccessRule: No password found in array");
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Verify passwordId and source.password exist
|
|
48
|
+
if (!HasProperty(latestPassword, "passwordId") ||
|
|
49
|
+
string.IsNullOrEmpty(latestPassword.passwordId?.ToString()))
|
|
50
|
+
{
|
|
51
|
+
LogWarning("PasswordGeneratedSuccessRule: passwordId is missing or empty");
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!HasProperty(latestPassword, "source") || latestPassword.source == null)
|
|
56
|
+
{
|
|
57
|
+
LogWarning("PasswordGeneratedSuccessRule: source is missing");
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!HasProperty(latestPassword.source, "password") ||
|
|
62
|
+
string.IsNullOrEmpty(latestPassword.source.password?.ToString()))
|
|
63
|
+
{
|
|
64
|
+
LogWarning("PasswordGeneratedSuccessRule: source.password is missing or empty");
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
LogInformation($"PasswordGeneratedSuccessRule: Password generated successfully - passwordId: {latestPassword.passwordId}");
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
using System.Threading.Tasks;
|
|
2
|
+
using BBT.Workflow.Scripting;
|
|
3
|
+
using BBT.Workflow.Scripting.Functions;
|
|
4
|
+
|
|
5
|
+
public class PhoneFetchedSuccessRule : ScriptBase, IConditionMapping
|
|
6
|
+
{
|
|
7
|
+
public async Task<bool> Handler(ScriptContext context)
|
|
8
|
+
{
|
|
9
|
+
if (!HasProperty(context.Instance?.Data, "personPhoneNumber"))
|
|
10
|
+
{
|
|
11
|
+
LogWarning("PhoneFetchedSuccessRule: personPhoneNumber not found");
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
var phoneData = context.Instance?.Data?.personPhoneNumber;
|
|
16
|
+
|
|
17
|
+
if (phoneData == null)
|
|
18
|
+
{
|
|
19
|
+
LogWarning("PhoneFetchedSuccessRule: personPhoneNumber is null");
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Check if fullNumber exists and is not empty
|
|
24
|
+
if (!HasProperty(phoneData, "fullNumber") || string.IsNullOrEmpty(phoneData.fullNumber?.ToString()))
|
|
25
|
+
{
|
|
26
|
+
LogWarning("PhoneFetchedSuccessRule: fullNumber is missing or empty");
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
LogInformation($"PhoneFetchedSuccessRule: Phone fetched successfully");
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using BBT.Workflow.Scripting;
|
|
4
|
+
using BBT.Workflow.Scripting.Functions;
|
|
5
|
+
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Mapping to reset password fail count in user instance after successful login.
|
|
8
|
+
/// </summary>
|
|
9
|
+
public class ResetPasswordFailCountMapping : ScriptBase, IMapping
|
|
10
|
+
{
|
|
11
|
+
public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
12
|
+
{
|
|
13
|
+
var directTask = (task as DirectTriggerTask)!;
|
|
14
|
+
|
|
15
|
+
// Get user key from userSnapshot
|
|
16
|
+
var userKey = string.Empty;
|
|
17
|
+
|
|
18
|
+
if (HasProperty(context.Instance?.Data, "userName"))
|
|
19
|
+
{
|
|
20
|
+
// Fallback to userName if userSnapshot is not available
|
|
21
|
+
userKey = context.Instance?.Data?.userName?.ToString();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (string.IsNullOrEmpty(userKey))
|
|
25
|
+
{
|
|
26
|
+
LogWarning("UpdatePasswordFailCountMapping: User key not found in instance data");
|
|
27
|
+
return new ScriptResponse
|
|
28
|
+
{
|
|
29
|
+
Data = new { error = "User key not found" }
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Set the instance key to update
|
|
34
|
+
directTask.SetKey(userKey);
|
|
35
|
+
|
|
36
|
+
// Build update body with password fail count increment
|
|
37
|
+
dynamic updateBody = new ExpandoObject();
|
|
38
|
+
updateBody.incrementPasswordFailCount = true;
|
|
39
|
+
updateBody.lastFailedLoginAt = DateTime.UtcNow;
|
|
40
|
+
|
|
41
|
+
// Include reason if available
|
|
42
|
+
if (HasProperty(context.Instance?.Data, "validationError"))
|
|
43
|
+
{
|
|
44
|
+
updateBody.lastFailReason = context.Instance?.Data?.validationError?.ToString();
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
{
|
|
48
|
+
updateBody.lastFailReason = "Invalid password";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
directTask.SetBody(updateBody);
|
|
52
|
+
|
|
53
|
+
LogInformation($"UpdatePasswordFailCountMapping: Updating password fail count for user={userKey}");
|
|
54
|
+
|
|
55
|
+
return new ScriptResponse();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public async Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
59
|
+
{
|
|
60
|
+
// Check if update was successful
|
|
61
|
+
if (HasProperty(context.Body, "data"))
|
|
62
|
+
{
|
|
63
|
+
LogInformation("UpdatePasswordFailCountMapping: Password fail count updated successfully");
|
|
64
|
+
|
|
65
|
+
return new ScriptResponse
|
|
66
|
+
{
|
|
67
|
+
Data = new
|
|
68
|
+
{
|
|
69
|
+
userResetPasswordFailCount = true,
|
|
70
|
+
updatedAt = DateTime.UtcNow
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
else
|
|
75
|
+
{
|
|
76
|
+
LogWarning("UpdatePasswordFailCountMapping: Failed to update password fail count");
|
|
77
|
+
|
|
78
|
+
return new ScriptResponse
|
|
79
|
+
{
|
|
80
|
+
Data = new
|
|
81
|
+
{
|
|
82
|
+
passwordFailCountUpdated = false,
|
|
83
|
+
error = "Failed to update password fail count"
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.Text.Json;
|
|
5
|
+
using BBT.Workflow.Definitions;
|
|
6
|
+
using BBT.Workflow.Scripting;
|
|
7
|
+
using BBT.Workflow.Scripting.Functions;
|
|
8
|
+
|
|
9
|
+
/// <summary>
|
|
10
|
+
/// Send OTP SMS Mapping - Sends OTP password via SMS using Messaging Gateway
|
|
11
|
+
/// This mapping uses phone number from Asgard and OTP from password generation
|
|
12
|
+
/// </summary>
|
|
13
|
+
public class SendOtpSmsMapping : ScriptBase, IMapping
|
|
14
|
+
{
|
|
15
|
+
public async Task<ScriptResponse> InputHandler(WorkflowTask task, ScriptContext context)
|
|
16
|
+
{
|
|
17
|
+
var httpTask = task as HttpTask;
|
|
18
|
+
if (httpTask == null)
|
|
19
|
+
{
|
|
20
|
+
throw new InvalidOperationException("Task must be an HttpTask for SMS sending");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Get MessagingServiceBaseUrl from secret
|
|
24
|
+
string messagingServiceBaseUrl = "http://host.docker.internal:5288/api";
|
|
25
|
+
try
|
|
26
|
+
{
|
|
27
|
+
var secretValue = await GetSecretAsync("vnext-secret", "workflow-secret", "MessagingService:BaseUrl");
|
|
28
|
+
if (!string.IsNullOrEmpty(secretValue))
|
|
29
|
+
{
|
|
30
|
+
messagingServiceBaseUrl = secretValue;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (Exception)
|
|
34
|
+
{
|
|
35
|
+
// Secret retrieval failed, use default address
|
|
36
|
+
// This is expected in development/local environment
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
httpTask.Url = httpTask.Url.Replace("{MessagingServiceBaseUrl}", messagingServiceBaseUrl);
|
|
40
|
+
|
|
41
|
+
// Get phone number from personPhoneNumber (from get-phone-from-person-task)
|
|
42
|
+
var personPhoneNumber = context.Instance?.Data?.personPhoneNumber;
|
|
43
|
+
if (personPhoneNumber == null)
|
|
44
|
+
{
|
|
45
|
+
LogWarning("SendOtpSmsMapping InputHandler: personPhoneNumber not found in instance data");
|
|
46
|
+
throw new InvalidOperationException("Phone number not found. Ensure get-phone-from-person task completed successfully.");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Get OTP from passwords array (from password generation)
|
|
50
|
+
if (!HasProperty(context.Instance?.Data, "passwords"))
|
|
51
|
+
{
|
|
52
|
+
LogWarning("SendOtpSmsMapping InputHandler: passwords array not found in instance data");
|
|
53
|
+
throw new InvalidOperationException("Passwords array not found. Ensure password generation completed successfully.");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var passwords = context.Instance?.Data?.passwords;
|
|
57
|
+
if (passwords == null || passwords is not IEnumerable<dynamic>)
|
|
58
|
+
{
|
|
59
|
+
LogWarning("SendOtpSmsMapping InputHandler: passwords is not an array");
|
|
60
|
+
throw new InvalidOperationException("Passwords must be an array.");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
var passwordList = ((IEnumerable<dynamic>)passwords).ToList();
|
|
64
|
+
if (passwordList.Count == 0)
|
|
65
|
+
{
|
|
66
|
+
LogWarning("SendOtpSmsMapping InputHandler: passwords array is empty");
|
|
67
|
+
throw new InvalidOperationException("No passwords found in array.");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Get latest password
|
|
71
|
+
var latestPassword = passwordList.LastOrDefault();
|
|
72
|
+
if (latestPassword == null || !HasProperty(latestPassword, "initialPassword"))
|
|
73
|
+
{
|
|
74
|
+
LogWarning("SendOtpSmsMapping InputHandler: initialPassword not found in latest password");
|
|
75
|
+
throw new InvalidOperationException("Plain text password (initialPassword) not found.");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var otp = latestPassword?.initialPassword?.ToString();
|
|
79
|
+
if (string.IsNullOrEmpty(otp))
|
|
80
|
+
{
|
|
81
|
+
LogWarning("SendOtpSmsMapping InputHandler: OTP password is empty");
|
|
82
|
+
throw new InvalidOperationException("OTP password is empty.");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Get citizenshipNo (TCKN) from person reference
|
|
86
|
+
string citizenshipNo = "UNKNOWN";
|
|
87
|
+
if (HasProperty(context.Instance?.Data, "person") && HasProperty(context.Instance?.Data?.person, "key"))
|
|
88
|
+
{
|
|
89
|
+
citizenshipNo = context.Instance?.Data?.person?.key?.ToString();
|
|
90
|
+
}
|
|
91
|
+
else
|
|
92
|
+
{
|
|
93
|
+
LogWarning("SendOtpSmsMapping InputHandler: person.key not found, falling back to instance key");
|
|
94
|
+
citizenshipNo = context.Instance?.Key ?? "UNKNOWN";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Get userId for logging
|
|
98
|
+
var userId = context.Instance?.Key ?? "UNKNOWN";
|
|
99
|
+
|
|
100
|
+
// Get passwordId for process itemId
|
|
101
|
+
var passwordId = latestPassword?.passwordId?.ToString() ?? Guid.NewGuid().ToString();
|
|
102
|
+
|
|
103
|
+
// Prepare template parameters as JSON string (CSX doesn't support JsonSerializer)
|
|
104
|
+
var templateParamsJson = "{\"Otp\":\"" + otp + "\",\"BrandName\":\"Burgan Bank\"}";
|
|
105
|
+
|
|
106
|
+
// Extract phone components from personPhoneNumber (new structure)
|
|
107
|
+
var countryCode = personPhoneNumber?.countryCode?.ToString() ?? "90";
|
|
108
|
+
var areaCode = personPhoneNumber?.areaCode?.ToString();
|
|
109
|
+
var number = personPhoneNumber?.number?.ToString();
|
|
110
|
+
|
|
111
|
+
if (string.IsNullOrEmpty(number))
|
|
112
|
+
{
|
|
113
|
+
throw new InvalidOperationException("Phone number is missing in personPhoneNumber data.");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Parse country code (remove + and leading zeros)
|
|
117
|
+
int countryCodeInt = 90; // default
|
|
118
|
+
if (!string.IsNullOrEmpty(countryCode))
|
|
119
|
+
{
|
|
120
|
+
var cc = countryCode.TrimStart('+').TrimStart('0');
|
|
121
|
+
int ccInt = 0;
|
|
122
|
+
if (int.TryParse(cc, out ccInt))
|
|
123
|
+
{
|
|
124
|
+
countryCodeInt = ccInt;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Parse areaCode (prefix)
|
|
129
|
+
int? prefixInt = null;
|
|
130
|
+
if (!string.IsNullOrEmpty(areaCode))
|
|
131
|
+
{
|
|
132
|
+
int pInt = 0;
|
|
133
|
+
if (int.TryParse(areaCode, out pInt))
|
|
134
|
+
{
|
|
135
|
+
prefixInt = pInt;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Prepare SMS request body
|
|
140
|
+
var smsRequest = new
|
|
141
|
+
{
|
|
142
|
+
template = "IbNewPasswordOtp",
|
|
143
|
+
templateParams = templateParamsJson,
|
|
144
|
+
smsType = "Otp",
|
|
145
|
+
phone = new
|
|
146
|
+
{
|
|
147
|
+
countryCode = countryCodeInt,
|
|
148
|
+
prefix = prefixInt,
|
|
149
|
+
number = number
|
|
150
|
+
},
|
|
151
|
+
citizenshipNo = citizenshipNo,
|
|
152
|
+
process = new
|
|
153
|
+
{
|
|
154
|
+
name = "IdmUtils",
|
|
155
|
+
itemId = passwordId,
|
|
156
|
+
action = "PasswordGeneration",
|
|
157
|
+
identity = citizenshipNo
|
|
158
|
+
},
|
|
159
|
+
sender = "AutoDetect"
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
httpTask.SetBody(smsRequest);
|
|
163
|
+
|
|
164
|
+
// Set Headers
|
|
165
|
+
var headers = new Dictionary<string, string?>
|
|
166
|
+
{
|
|
167
|
+
["Content-Type"] = "application/json"
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// Set Authorization header if available
|
|
171
|
+
try
|
|
172
|
+
{
|
|
173
|
+
var authToken = await GetSecretAsync("vnext-secret", "workflow-secret", "MessagingService:Authorization");
|
|
174
|
+
if (!string.IsNullOrEmpty(authToken))
|
|
175
|
+
{
|
|
176
|
+
headers["Authorization"] = authToken;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
catch (Exception)
|
|
180
|
+
{
|
|
181
|
+
// Authorization secret not found, continue without it
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
httpTask.SetHeaders(headers);
|
|
185
|
+
|
|
186
|
+
LogInformation($"SendOtpSmsMapping InputHandler: phone={number}, userId={userId}, citizenshipNo={citizenshipNo}, passwordId={passwordId}");
|
|
187
|
+
|
|
188
|
+
return await Task.FromResult(new ScriptResponse());
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
public async Task<ScriptResponse> OutputHandler(ScriptContext context)
|
|
192
|
+
{
|
|
193
|
+
try
|
|
194
|
+
{
|
|
195
|
+
var statusCode = GetStatusCodeFromResponse(context);
|
|
196
|
+
var responseData = GetResponseDataFromContext(context);
|
|
197
|
+
|
|
198
|
+
// Successful SMS sending
|
|
199
|
+
if (statusCode >= 200 && statusCode < 300 && responseData != null)
|
|
200
|
+
{
|
|
201
|
+
// Safely extract response fields
|
|
202
|
+
string txnId = null;
|
|
203
|
+
if (HasProperty(responseData, "txnId"))
|
|
204
|
+
txnId = responseData.txnId?.ToString();
|
|
205
|
+
else if (HasProperty(responseData, "TxnId"))
|
|
206
|
+
txnId = responseData.TxnId?.ToString();
|
|
207
|
+
|
|
208
|
+
string status = "Sent";
|
|
209
|
+
if (HasProperty(responseData, "status"))
|
|
210
|
+
status = responseData.status?.ToString() ?? "Sent";
|
|
211
|
+
else if (HasProperty(responseData, "Status"))
|
|
212
|
+
status = responseData.Status?.ToString() ?? "Sent";
|
|
213
|
+
|
|
214
|
+
string messageId = null;
|
|
215
|
+
if (HasProperty(responseData, "messageId"))
|
|
216
|
+
messageId = responseData.messageId?.ToString();
|
|
217
|
+
else if (HasProperty(responseData, "MessageId"))
|
|
218
|
+
messageId = responseData.MessageId?.ToString();
|
|
219
|
+
|
|
220
|
+
return new ScriptResponse
|
|
221
|
+
{
|
|
222
|
+
Data = new
|
|
223
|
+
{
|
|
224
|
+
smsDelivery = new
|
|
225
|
+
{
|
|
226
|
+
success = true,
|
|
227
|
+
messageId = messageId,
|
|
228
|
+
txnId = txnId,
|
|
229
|
+
status = status,
|
|
230
|
+
sentAt = DateTime.UtcNow
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
// Failed SMS sending
|
|
236
|
+
else
|
|
237
|
+
{
|
|
238
|
+
var errorInfo = ExtractErrorInformation(context, statusCode);
|
|
239
|
+
LogWarning($"SendOtpSmsMapping OutputHandler: Failed to send SMS - {errorInfo.message}");
|
|
240
|
+
|
|
241
|
+
return new ScriptResponse
|
|
242
|
+
{
|
|
243
|
+
Data = new
|
|
244
|
+
{
|
|
245
|
+
smsDelivery = new
|
|
246
|
+
{
|
|
247
|
+
success = false,
|
|
248
|
+
error = errorInfo.message,
|
|
249
|
+
errorCode = errorInfo.code,
|
|
250
|
+
errorDescription = errorInfo.description,
|
|
251
|
+
statusCode = statusCode,
|
|
252
|
+
sentAt = DateTime.UtcNow
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
catch (Exception ex)
|
|
259
|
+
{
|
|
260
|
+
LogError($"SendOtpSmsMapping OutputHandler: Exception - {ex.Message}");
|
|
261
|
+
return new ScriptResponse
|
|
262
|
+
{
|
|
263
|
+
Data = new
|
|
264
|
+
{
|
|
265
|
+
smsDelivery = new
|
|
266
|
+
{
|
|
267
|
+
success = false,
|
|
268
|
+
error = "Internal processing error",
|
|
269
|
+
errorCode = "processing_error",
|
|
270
|
+
errorDescription = ex.Message,
|
|
271
|
+
sentAt = DateTime.UtcNow
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
#region Helper Methods
|
|
279
|
+
|
|
280
|
+
private static int GetStatusCodeFromResponse(ScriptContext context)
|
|
281
|
+
{
|
|
282
|
+
if (context.Body?.statusCode != null)
|
|
283
|
+
return (int)context.Body.statusCode;
|
|
284
|
+
|
|
285
|
+
return 200;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
private static dynamic? GetResponseDataFromContext(ScriptContext context)
|
|
289
|
+
{
|
|
290
|
+
if (context.Body?.data != null)
|
|
291
|
+
return context.Body.data;
|
|
292
|
+
|
|
293
|
+
if (context.Body != null && context.Body.statusCode == null)
|
|
294
|
+
return context.Body;
|
|
295
|
+
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
private (string message, string code, string description) ExtractErrorInformation(ScriptContext context, int statusCode)
|
|
300
|
+
{
|
|
301
|
+
string message = "SMS sending failed";
|
|
302
|
+
string code = "sms_sending_error";
|
|
303
|
+
string description = "Unable to send SMS";
|
|
304
|
+
|
|
305
|
+
// Try to extract error from response body
|
|
306
|
+
try
|
|
307
|
+
{
|
|
308
|
+
if (context.Body != null && HasProperty(context.Body, "data"))
|
|
309
|
+
{
|
|
310
|
+
var data = context.Body.data;
|
|
311
|
+
if (data != null && HasProperty(data, "error"))
|
|
312
|
+
{
|
|
313
|
+
var errorData = data.error;
|
|
314
|
+
if (errorData != null)
|
|
315
|
+
{
|
|
316
|
+
if (HasProperty(errorData, "message"))
|
|
317
|
+
message = errorData.message?.ToString() ?? message;
|
|
318
|
+
if (HasProperty(errorData, "code"))
|
|
319
|
+
code = errorData.code?.ToString() ?? code;
|
|
320
|
+
if (HasProperty(errorData, "description"))
|
|
321
|
+
description = errorData.description?.ToString() ?? description;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
catch
|
|
327
|
+
{
|
|
328
|
+
// If error extraction fails, use defaults
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// If no error details found in response, set based on status code
|
|
332
|
+
if (code == "sms_sending_error")
|
|
333
|
+
{
|
|
334
|
+
if (statusCode == 400)
|
|
335
|
+
{
|
|
336
|
+
code = "invalid_sms_parameters";
|
|
337
|
+
description = "Invalid SMS request parameters";
|
|
338
|
+
}
|
|
339
|
+
else if (statusCode == 401 || statusCode == 403)
|
|
340
|
+
{
|
|
341
|
+
code = "unauthorized";
|
|
342
|
+
description = "Unauthorized access to SMS service";
|
|
343
|
+
}
|
|
344
|
+
else if (statusCode >= 500)
|
|
345
|
+
{
|
|
346
|
+
code = "sms_service_error";
|
|
347
|
+
description = "Internal server error in SMS service";
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return (message, code, description);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
#endregion
|
|
355
|
+
}
|
|
356
|
+
|
|
@@ -7,7 +7,8 @@ using System;
|
|
|
7
7
|
|
|
8
8
|
/// <summary>
|
|
9
9
|
/// User Password Generator Mapping - Generates numeric OTP password for user authentication
|
|
10
|
-
/// This mapping calls the password generation service and returns the password with its hash.
|
|
10
|
+
/// This mapping calls the password generation service (without Asgard/SMS) and returns the password with its hash.
|
|
11
|
+
/// Note: Asgard phone fetch and SMS sending are now handled by separate workflow tasks.
|
|
11
12
|
/// </summary>
|
|
12
13
|
public class UserPasswordGeneratorMapping : ScriptBase, IMapping
|
|
13
14
|
{
|
|
@@ -20,6 +21,7 @@ public class UserPasswordGeneratorMapping : ScriptBase, IMapping
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
string utilBaseAddress = "http://host.docker.internal:5288/api";
|
|
24
|
+
|
|
23
25
|
try
|
|
24
26
|
{
|
|
25
27
|
var secretValue = await GetSecretAsync("vnext-secret", "workflow-secret", "UtilBaseAddress");
|
|
@@ -34,6 +36,7 @@ public class UserPasswordGeneratorMapping : ScriptBase, IMapping
|
|
|
34
36
|
// This is expected in development/local environment
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
|
|
37
40
|
httpTask.Url = httpTask.Url.Replace("{UtilBaseAddress}", utilBaseAddress);
|
|
38
41
|
|
|
39
42
|
// Prepare the request body for password generation
|
|
@@ -41,10 +44,9 @@ public class UserPasswordGeneratorMapping : ScriptBase, IMapping
|
|
|
41
44
|
{
|
|
42
45
|
length = HasProperty(context.Instance?.Data,"passwordLength") ? context.Instance?.Data?.passwordLength : 6,
|
|
43
46
|
userId = context.Instance?.Key ?? "default-user",
|
|
44
|
-
reference = HasProperty(context.Instance?.Data, "
|
|
45
|
-
HasProperty(context.Instance?.Data?.
|
|
46
|
-
|
|
47
|
-
? context.Instance?.Data?.user?.person?.key
|
|
47
|
+
reference = HasProperty(context.Instance?.Data, "person") &&
|
|
48
|
+
HasProperty(context.Instance?.Data?.person, "key")
|
|
49
|
+
? context.Instance?.Data?.person?.key
|
|
48
50
|
: "User",
|
|
49
51
|
expiryDays = HasProperty(context.Instance?.Data, "passwordExpiryDays") ? context.Instance?.Data?.passwordExpiryDays : 90
|
|
50
52
|
};
|
|
@@ -75,11 +77,36 @@ public class UserPasswordGeneratorMapping : ScriptBase, IMapping
|
|
|
75
77
|
// Successful password generation
|
|
76
78
|
if (statusCode >= 200 && statusCode < 300 && responseData?.Success == true)
|
|
77
79
|
{
|
|
80
|
+
// Create password entry matching schema structure
|
|
81
|
+
var passwordEntry = new
|
|
82
|
+
{
|
|
83
|
+
type = "Password",
|
|
84
|
+
passwordId = responseData.PasswordId,
|
|
85
|
+
initialPassword = responseData.Password, // Plain text password
|
|
86
|
+
source = new
|
|
87
|
+
{
|
|
88
|
+
password = responseData.HashedPassword, // Hashed password
|
|
89
|
+
algorithm = responseData.Algorithm ?? "pbkdf2-hmacsha256",
|
|
90
|
+
lastUpdatedDate = responseData.GeneratedAt
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Get existing passwords array or create new one
|
|
95
|
+
var existingPasswords = new List<dynamic>();
|
|
96
|
+
if (HasProperty(context.Instance?.Data, "passwords") &&
|
|
97
|
+
context.Instance?.Data?.passwords != null)
|
|
98
|
+
{
|
|
99
|
+
existingPasswords = ((IEnumerable<dynamic>)context.Instance.Data.passwords).ToList();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Add new password to array
|
|
103
|
+
existingPasswords.Add(passwordEntry);
|
|
104
|
+
|
|
78
105
|
return new ScriptResponse
|
|
79
106
|
{
|
|
80
107
|
Data = new
|
|
81
108
|
{
|
|
82
|
-
|
|
109
|
+
passwords = existingPasswords // Store in schema-compliant array
|
|
83
110
|
}
|
|
84
111
|
};
|
|
85
112
|
}
|