首页 > 解决方案 > F3 路由和动态参数(验证用户注册)

问题描述

我尝试使用 fatfree 框架来完成验证用户注册。

    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

测试结果:

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

我如何在路由中管理它?

我尝试了什么:

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

我很困惑,由于参数显然是动态的,如何设置路线?或者有没有其他方法可以验证注册/他来自发送给他的电子邮件中的正确链接?

谢谢!

标签: phpauthenticationroutesfat-free-frameworkemail-verification

解决方案


在一些帮助下弄清楚了:

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

然后检查是否 isset

    $params['vkey']

推荐阅读