48
Views
9
Comments
Solved
OTP Generation

Hi all,

I've created a 'GenerateOTP' service in ODC, but I've noticed the OTP generation is inconsistent. Specifically, the OTP should always be 8 digits long, but during testing, I found that my logic may have some issues.

To troubleshoot, I converted the test screen to O11, and the same behaviour persists. Just to note, in ODC we are using the CryptoRandomInt function instead of GetRandomInt in O11.

Could someone help me pinpoint if there's a logic error on my end, or is this expected behaviour within the OutSystems platform? This service is essential for our application, so I’d appreciate any insights.

Thanks!

TestingOTP.oml
2024-07-12 05-57-50
Gourav Shrivastava
Champion
Solution

Hello AndrĂ© Smit 

Please try this OML and open it in your personal O11 service studio . I just changed the if condition you can check here

Thanks 

Regards Gourav Shrivastava

OTP_Test.oml
2024-12-18 16-06-42
Junaid Syed

Hello,

Since you are using a forge component and having issues with that, I would suggest you to initiate the discussion on component page to report your issue. Hopefully the concerned team will be able to assist you better.

Thanks,

Junaid

2024-07-12 05-57-50
Gourav Shrivastava
Champion

Hello André Smit

In this logic :-


I have found two suggestions:- 

1) Why are you generation integers one by one instead of once by adding 0 to 99999999

2) And you are not reinitializing the counter variable if the code is not successfully generated.




Thanks 

Regards Gourav Shrivastava


2023-02-06 14-27-11
André Smit

Hi @Junaid Syed, thank you for your comment. I think there might have been a misunderstanding—I’m not using a Forge component. We’re currently developing in ODC, and I converted the screen to O11 because many users don’t yet have access to ODC.


@Gourav Shrivastava, thank you for highlighting the issues in my logic. However, I think that with your point number #1, it should stay as is. I am quickly doing further testing on my end.

EDIT: Never mind, I see it is still breaking... If I can numMax to 99999999 it just generates the '0000 0000' and the output just returns '0'.

2024-12-18 16-06-42
Junaid Syed

You might need to share the updated OML then, since the original one does have the reference to the extension from forge.

2023-02-06 14-27-11
André Smit


My apologies @Junaid Syed - I see what you mean. I was under the impression it is a system action.

This makes it a bit trickier since in ODC there is a native server action. I might be mistaken but don't think it is the Forge component giving problems but rather my way of implementing the solution.

Hope this makes sense.

In ODC


2024-07-12 05-57-50
Gourav Shrivastava
Champion

Hello André Smit

I have made some changes to your code please check 

Thanks 

Regards Gourav Shrivastava

TestOTP.oml
2023-02-06 14-27-11
André Smit

Thanks for your effort, @Gourav Shrivastava.

I tried opening your OML.

2024-07-12 05-57-50
Gourav Shrivastava
Champion
Solution

Hello AndrĂ© Smit 

Please try this OML and open it in your personal O11 service studio . I just changed the if condition you can check here

Thanks 

Regards Gourav Shrivastava

OTP_Test.oml
UserImage.jpg
Rounak Rawat

Hi André Smit ,

If you’re looking to generate an OTP, I suggest trying the Generate Password (length, includeSpecialCharacters) function, which I've used before with good results. Although it’s typically for passwords, it works well for OTPs by creating random, secure codes.

  • Use false for include Special Characters to restrict the OTP to alphanumeric characters only, or customize based on your needs.

Thanks

Rounak Rawat

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.