gpt4 book ai didi

php - 如果帐户未激活,Laravel 会重定向

转载 作者:行者123 更新时间:2023-11-29 12:31:45 24 4
gpt4 key购买 nike

我将粘贴代码,以便您了解我想要做什么,基本上我制作了一个路由过滤器,并告诉我要在用户帐户未激活时重定向(我通过电子邮件链接进行)。

Route::filter('activated', function()
{
if (Session::get('account_activated') == 0)
{
return Redirect::to('myaccount', 'MyAccountController@notActive');
}
});

Route::group(array('before' => 'auth'), function()
{
// Only authenticated users may enter...
Route::get('myaccount', 'MyAccountController@index');
});

当我登录时,我将“account_activated”键与数据库中的值(对应于用户)放入 session 中,所以...当我尝试进入此处时:

Route::group(array('before' => array('auth', 'activated')), function()
{
// Only authenticated and activated users may enter...
Route::get('sell', 'SellController@index');
});

我收到此错误:HTTP 状态代码“0”无效。有谁知道这是为什么吗?谢谢!

最佳答案

当您想对一条路由使用多个过滤器时,必须将它们放在一个字符串中,并用 | 分隔。

Route::group(array('before' => 'auth|activated'), function()
{
// Only authenticated and activated users may enter...
Route::get('sell', 'SellController@index');
});

更新:状态码 0 表示 Laravel 执行请求时出现问题。发生这种情况时最好查看 Laravel 日志或网络服务器日志。

关于php - 如果帐户未激活,Laravel 会重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27382677/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com