Search code examples
phpauthenticationroutesfat-free-frameworkemail-verification

F3 route and dynamic parameter (verify user registration)


I try to accomplish verifying a user registration, using fatfree framework.

    1. user registers account on: website/register
    2. I save the user data including a verification key
    3. he gets an email sent to the email he provided
    4. the email contains the link (http://website/register/verify.php?vkey=$vkey) for verification 
    5. user clicks the link and gets sent to website/register/verify.php?vkey=91cb65b234b0b5d67df68e0d7f72ed7e
    6. on the website I check if isset a verification key, and
    7. get the verification key stored in db and compare it with ?vkey=$vkey
    8. if they match, all good, reroute

test result:

    Not Found
    HTTP 404 (GET ../register/verify.php?vkey=91cb65b234b0b5d67df68e0d7f72ed7e)

How do I manage that in routing?

What I tried:

    $f3->route('GET /register/verify/@vkey', 'Controller\UserController->registerverified');
    $f3->route('GET /register/verify.php?vkey=', 'Controller\UserController->registerverified');

I`m confused, how to set the route since the paramater is dynamic obviously? Or is there any other way how to verify the registration / that he comes from the right link within the email sent to him?

Thanks!


Solution

  • Got it figured out with some help:

        $f3->route('GET /register/verify/@vkey', 'Controller\UserController->registerverified');
    

    And then check if isset

        $params['vkey']