Disposable password

Dear friend
I am Hamed,one of the Zapwork competition winners.
I want to know how can we create disposable passwords for users? for example for a printed game we want to use a password that the user can use that once then the password expire.
Please guide me
Thank you

2 Likes

Hi Hamed,

Hope you’re well.

It’s certainly an interesting concept. What kind of password system did you have in mind?

Are they randomly generated one-use passwords, or more like preset passwords used to unlock further features (much like games in the 80s)?

Thanks,
Seb

2 Likes

Hi Seb
Thank you.
I want second type(preset password for unlocking new features).
I will be very grateful if you help me in solving this problem.
Best regards
Hamed

1 Like

Hi @seyed.kamali,

Thanks for the response. We’ll look into the possibility of covering this functionality in a future tutorial :slight_smile:

In the meantime, you could try the following steps:

  1. Create a string variable that contains your password
  2. Use Z.Prompt to ask the user for an input
  3. Save the user’s input to a new string variable
  4. Check whether the two strings match
  5. If they do, perform the relevant functionality e.g. activating a state, playing a timeline animation, showing a new screen symbol etc.

Hope this helps. Let me know if you have any questions.

All the best,
Seb

2 Likes

Thanks Seb
I will try this,I hope that can help me.
Kind regards
Hamed
:pray:

3 Likes

Hi @Seb
I hope you have a good time.
I tried below code but it doesn’t work,please guide me in solving this problem.
Thank you
HamedproMpt-cod-pass1

1 Like

Hey @seyed.kamali,

Looks like your code isn’t working because your if/else statement isn’t being called. Try to put it on the pass.on(“confirm”) block, like this:

pass.on("confirm", function(pass){
    if(condition1){
        //expected result1
    }else if(condition2){
        //expected result2
    }
}); 

In this way, when you click on confirm button, the if else will be checked and your result will be show.

Also you can create a function with this if/else statement in and just call on confirm or wheatever you want but by looking like this is this your problem.

att, HigĂŁo.

1 Like

Hi Higor @seb
Thanks for your reply.please check below picture,I think probably I have defined my conditions wrong and for this problem I have written wrong my codes basically.
please guide me.
Best Regards
hamedpass-code2

1 Like

Hello @seyed.kamali

Sorry by the late response! I’ve done here a quick example of this working and I’ll try to explain u, why aren’t urs working! Here:

image

In rose we have our codes/passwords (I just setted “a” to be easily to test and explain).

In green we have the var which receives the user input;

In dark blue we have the defaultValue.

First of everything, I don’t know if you understand wrong or you were doin’ just your logic but defaultValue is just what will be wrote in the text camp when the prompt opens, so it don’t have nothing with what you were trying to do!

Now here, when you create your variable that will be the right code, you have to compare it with the variable which received the user’s input (in my case code (password) compare with text). Basically rose compares with green!

In your case you were comparing the variable defaultValue (which is equal to 12345 in string type) with a string “12345”, instead of compare it to pass. If you try my example you will see that if you set “a” as answer in the prompt text box, the plane will turn red, if is anything else, the plane became green!

EDIT1:

Your code should work properly in this way:

image

Also, I don’t see why use else if to do the second result if the input isn’t equal to the pass value. Just a simple if/else statement should work!

Hope you understand till here,

att, HigĂŁo.

3 Likes

Hi @Higor
Thank you so much for your guidance.
As I mentioned in the picture three passwords work correctly.
Until step 2 everything is OK but I need to use many passwords also, the passwords are stored on devices and no longer need to enter a password and can only be used once.
Kind Regards
Hamed
password-c3

2 Likes

Hi @Seb
I wish you have a good time.
I’ll be grateful if anyone can help me fix this problem.
Kind Regards

2 Likes

Hi @seyed.kamali,

I have created an example project to show how a password can be set up in ZapWorks Studio.

You are very close, but in your project you are trying to compare the default text property of the Z.prompt object interface. This will always return false as you are comparing “inter your pass” with “123456” or “23456” or “345676”.

What is needed is a comparison of the myprompt variable (in your example, or inputtedPassword in mine) because this is the saved user inputted value.

The example I have created can be downloaded here: Disposable Passwords.zpp (94.7 KB)

It is fully commented so should explain itself, but if you have any further questions then please let us know.

Hope this helps.

George

2 Likes

Dear @George
Thanks for your guidance,I want to help me for lots of OTPs (one time passwords) in my Zapwork project’s code then that passwords saved to the user’s devices.
Best Regards
Hamed

1 Like

Hi,
as a total beginner, is there any chance you can produce the code needed to enter in a password to unlock a screen? Also, is it possible to do something like this in the new Designer?
Thank you
@lasdonpark.org