Is it posible to autogenerate characters at the server connect level?

Hi I am working in a user registration form, the current workflow for the server connect is

Validate data
password hash
Database insert
Setup mailer
Email send
image

The above works perfectly! However, I am trying to add an account verification step, where the user will receive an email with a validation url and a code they need to add to fully validate their account.

I am able to create the email and the validation url. However, I want the code to be auto generated at the server level, for security reasons. But I do not know how to do it in wappler.

Does anyone know how to do this?

Thanks

Juan

What server target are you using? PHP? NodeJS?

For NodeJS I use this Wappler extension to generate a random string:

1 Like

Why not use the UUID option available in the data picker in Server Connect?

It will generate an unique UUID like be92e232-e54b-4677-acc7-db852aca5b82

2 Likes

Hi @Teodor, thank you so much for the information! didn’t know you could do that! it works perfectly!
Regards
J

1 Like

@Apple thank you so much for the suggestion and for taking the time to read my question :slight_smile:

Hi @Teodor,

Just one more thing, using the UUID works perfectly as the information is added to the DB!

However, how can I retrieve this information, so that it can be sent by email?

Thanks

J

Just be aware that the UUID global produces a new value each time it is used. If you want to be able to use the same value in a database action and an email step you could either:

  • do a DB query to retrieve it once it was inserted/updated
    or
  • use a Set Value step to assign the UUID and then use that to add to the DB and in the email
4 Likes

Hi @bpj thanks a lot for the feedback, that was the issue i was running into, but your options fixed it!
Regards
J

1 Like

if you checkout my new video series I do exactly what you ask. In this module I show you how to use a simple algorithm to generate a random code of any length which can include numbers, letters or special characters.

1 Like

@Hyperbytes, I am running into some issues when I trying to implement your video. I think the error is when I am trying to split string. I have tried all your steps and that is the only one that returns an error.

The split string step

The error:


{“code”:0,“file”:"/home/n8ff585//dmxConnectLib/lib/db/Connection.php",“line”:141,“message”:“Array to string conversion”,“trace”:"#0 [internal function]: exception_error_handler(8, ‘Array to string…’, ‘/home/n8ff585/g…’, 141, Array)\n#1 /home/n8ff585/gen-1-5-dev3.a11yn.io/dmxConnectLib/lib/db/Connection.php(141): PDOStatement->bindParam(5, Array, 2)\n#2 /home/n8ff585/gen-1-5-dev3.a11yn.io/dmxConnectLib/modules/dbupdater.php(164): lib\db\Connection->execute(‘INSERT INTO `AN…’, Array, false, ‘ANG_users’)\n#3 /home/n8ff585/gen-1-5-dev3.a11yn.io/dmxConnectLib/lib/App.php(197): modules\dbupdater->insert(Object(stdClass), ‘scUsersSelfRegi…’, Array)\n#4 /home/n8ff585/gen-1-5-dev3.a11yn.io/dmxConnectLib/lib/App.php(169): lib\App->execSteps(Object(stdClass))\n#5 /home/n8ff585/gen-1-5-dev3.a11yn.io/dmxConnectLib/lib/App.php(137): lib\App->execSteps(Array)\n#6 /home/n8ff585/gen-1-5-dev3.a11yn.io/dmxConnectLib/lib/App.php(126): lib\App->exec(Object(stdClass), false)\n#7 /home/n8ff585/gen-1-5-dev3.a11yn.io/dmxConnectLib/lib/App.php(104): lib\App->exec(Object(stdClass))\n#8 /home/n8ff585/gen-1-5-dev3.a11yn.io/dmxConnect/api/Users/apiUsersSelfRegistration.php(8): lib\App->define(Object(stdClass))\n#9 {main}"}

I am sure I am doing something wrong, but not sure what it is. any help is very much appreciated.

Thanks
J

The error message seems to point to the Insert statement, can I see that?

You also seem to have missed out the randomise action and the repeat to build the code string

image

1 Like

Hi @Hyperbytes, yes the first time I did it I missed adding one of of the global values.
It works perfectly.
Thanks a lot for your help!
Regards
J

1 Like