【问题标题】:Sentry is not working on my live serverSentry 无法在我的实时服务器上运行
【发布时间】:2015-11-03 07:02:32
【问题描述】:

我在我的 laravel 4.2 中使用 "cartalyst/sentry": "2.1.*"

在我的本地服务器上一切正常,但我无法在实时服务器上使用哨兵。

我的问题是我无法在 routes.php 上获取 Sentry 用户

$credentials = array("email" => $postData["email"], "password" => $postData["password"]);

        // Authenticate the user
        $user = Sentry::authenticate($credentials, false);
        if ($user) {
            // its redirecting fine for both usres
            if($user->hasAccess('admin')){
              return Redirect::to('admin/index');                   
            }
            if($user->hasAccess('Advertiser')){
              return Redirect::to('advertiser');
            }

这里一切正常,我可以通过Sentry::getUser() 获取用户,还可以检查用户的访问权限,并且还可以重定向到特定的路由。

但是在我的 routes.php 上

Route::get('advertiser', ['as' => 'advertiser' function () {
// I am not getting user here, and it redirects user to index route
if (!Sentry::check()) {
    return Redirect::to('index');
} 
else {
    return View::make('advertiser-home');
}
}]);

我检查了很多,但没有发现哨兵在任何页面上工作。

请帮帮我。

【问题讨论】:

  • 没有错误信息?只是 Sentry::check() 总是返回 false?
  • 与其检查用户是否直接在路由中进行身份验证,不如创建一个过滤器并将其应用于路由。
  • 你检查过你的应用程序日志吗,app/storage/logs/laravel.log
  • 我也面临同样的问题。有没有人发现什么?我的代码在 vps 上,它没有记录任何内容。需要帮助

标签: php laravel cartalyst-sentry


【解决方案1】:

这是由于缓存造成的。我所做的是按照以下命令运行:

php artisan route:clear
php artisan config:clear

通过这些命令,我​​的debugbarSentry 都开始工作了。如果您仍然遇到任何问题,请尝试

php artisan view:clear

我正在使用 Laravel 5.2,这些命令有助于使两者都能正常工作。

【讨论】:

  • 确保在您对生产站点进行的任何部署中运行上面两个命令,否则一般情况下您将度过一段糟糕的时光
猜你喜欢
  • 2014-03-27
  • 1970-01-01
  • 2017-08-11
  • 2016-12-04
  • 1970-01-01
  • 1970-01-01
  • 2017-04-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多