Sending authoriztion code to confirm account

Hi @teodor
I'm not at my desk to be able to check but is there a difference between PHP and Node when a set value is empty? Does it throw an error in PHP rather than just initialise as empty in NodeJS? That might be causing the confusion

I think it would be good if both initialised to null if left empty

bpj - This is my question as well ! Thanks for asking .

Hi @teodor
I'm not at my desk to be able to check but is there a difference between PHP and Node when a set value is empty? Does it throw an error in PHP rather than just initialise as empty in NodeJS? That might be causing the confusion

I think it would be good if both initialised to null if left empty

There are some small differences between node and PHP.
The tutorial is a node tutorial and untested with php so some minor tweaks may be necessary.
I suggest initialising the variable to null which should work

that's a nice way to do it

randomarray.top(6).join('','')

For tutorials i try not to concatenate functions, rather doing them in stages as it makes things easier to follow (remember these tutorials are aimed at novices)

I guess that makes my thought processes follow that same single step mentality

UPDATE: Just realized this might not work due to you using PHP. Please disregard.

Seems like a lot of work to create a random code. Here's another way that might be helpful.

Create a radomizer custom formatter.
image

components.hjson

[
  {
    type: 'method_randomizer',
    groupTitle: 'Cryptographic',
    groupIcon: 'fa fa-lg fa-check-circle',
    addTitle: 'Randomizer',
    title: 'Randomizer',
    icon: 'fa fa-lg fa-hashtag',
    state: 'opened',
    help: 'Generate 6 digit random number',
    properties: []
  }
]

randomatic.js

const randomizer = require('randomatic');

exports.randomizer = function () {
    return randomizer('0', 6);
}

Then use {{randomizer()}} where needed.

The idea behind the code is to be a universal method which can include numbers, letters, upper and lower case as well a special characters with the provision to introduce repeats.

Having said that, the tutorial is old and I have since released a node extension which is a much better solution for node users.

OP needs php solution, so neither of our posts will help.

@webdesignBCMS
The tutorial was made for NodeJS, maybe on PHP some steps may not work as expected.
In this case you should try another method to create a random number.

You can use
{{TIMESTAMP.substr(-6, 0)}}

That will retrieve last 6 digits of the timestamp value:

If timestamp is: 1741284953
Then the value will be: 284953

You can also multiply it to a number and add more randomness:
(TIMESTAMP * 1852).substr(-6, 0)

2 Likes

That is a brilliant idea using a Timestamp String. Wish I had thought of that a few years ago.

1 Like

Huge thanks to the Wappler community for your help in solving my coding issue! Your support, insights, and expertise made all the difference. Grateful to be part of such an awesome and helpful community!
I used franse suggestion of the TIMESTAMP string. Took out the repeat6 step and all setvalue steps,added the Set Value mycode = {{TIMESTAMP.substr (-6, O)}} to "mycode" and that gave mycode a value that it needed.
Many thanks to everone!

1 Like

I just removed my email authorization code feature because (1) my domain is fairly new, (2) the large mail exchange providers like google and hotmail consider my emails spam often, and (3) customers weren't seeing the authorization email and getting frustrated.

This is an issue with sending authorization emails from newer domains. Yes, you can jump through a few hoops to limit how many MX's classify your email as spam, but it's always a risk.

Instead of an email authorization, I put the Stripe checkout process first, and then redirect to my signup page upon successful charging of the payment method. There's no free usage of my app, so every customer must have a legit form of payment. Authorizations were just an additional step that didn't improve the customer's initial experience with registering with my app. It was more of a geeky thing we can do in Wappler (works perfectly) but not really offering a benefit to me or the user.

1 Like

Just out of curiosity, did you have SPF, DKIM, and DMARC set up? Might also help to have ARC set up.