首页 文章

使用Laravel 3通过电子邮件激活帐户

提问于
浏览
0

我正在尝试使用新用户电子邮件和哈希来通过电子邮件验证用户帐户 . 我的路由出了点问题,因为点击链接时出现404错误 .

我发送给用户的URL如下所示:

http://mywebsite.com/users/verify/<email>/<hash>

我的整个用户控制器已注册...

Route::controller('users');

我在用户控制器中的功能如下...只是试图让我的功能触发,但我得到404错误 .

// VERIFY NEW USER
public function post_verify($email, $hash) {
   echo "$email Acct verified with $hash!";
}

这看起来很简单 . 我的控制器很安静 . 为什么路由不正确?

谢谢!

2 回答

  • 0

    你是 sending 一个 URL 给用户,所以当他们 Open 时,他们实际上发送了一个 GET 请求!

    在你的 Controller 你正在等待 POST 请求:)所以它发生了_274246!因为没有 form 被用户填写和发布!
    正如Aleksey所说,改变如下:

    // VERIFY NEW USER
    public function get_verify($email, $hash) {
       echo "{$email} Acct verified with {$hash}!";
    }
    
  • 0

    您只需要在控制器中使用get方法替换post方法:get_verify($ email,$ hash)而不是post_verify($ email,$ hash)

    // VERIFY NEW USER
    public function get_verify($email, $hash) {
       echo "$email Acct verified with $hash!";
    }
    

相关问题