【问题标题】:Laravel Authentication Issue for Version 5.1Laravel 5.1 版本的身份验证问题
【发布时间】:2016-10-03 02:34:42
【问题描述】:

我有身份验证问题。在 5.1 版中,它在本地运行良好,但在服务器上出现奇怪的错误。 check() 函数总是返回 false,但我在身份验证控制器中进行了调试,我在 attempt() 函数中得到了 true,但为什么 check() 在重定向后返回 false?

配置/auth.php:

return [

    'driver' => 'eloquent',
    'model' => 'App\Company',
    'table' => 'company',
    'password' => [
        'email' => 'emails.password',
        'table' => 'password_resets',
        'expire' => 60,
    ],
];

公司模型类

<?php

namespace Testnamespace;

use Cviebrock\EloquentSluggable\SluggableInterface;
use Cviebrock\EloquentSluggable\SluggableTrait;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Route;
use Sofa\Eloquence\Eloquence;

class Company extends Model implements AuthenticatableContract, CanResetPasswordContract, SluggableInterface
{

    use Authenticatable, CanResetPassword, SoftDeletes, SluggableTrait, Eloquence;

    public $timestamps = true;
    protected $table = 'company';
    protected $dates = ['deleted_at'];
    protected $fillable = [
        'email',
        'password',
        'name',
        'info',
        'extra_info',
        'phone',
        'mobile',
        'street',
        'postal_code',
        'website',
        'facebook',
        'newsletter'
    ];
    protected $sluggable = [
        'build_from' => 'name',
        'save_to' => 'slug',
    ];
    protected $searchableColumns = ['name'];
    protected $primaryKey = 'id';


}

【问题讨论】:

  • 错误信息是什么?
  • 没有错误信息但 auth::check() 函数返回 false
  • 除了 config/auth.php 和 config/session.php 之外还需要任何其他配置吗??
  • 你检查过错误日志吗?或使用正确的域检查会话?
  • 我检查了错误日志,没有错误,并尝试在 config/session.php 中设置域,但问题仍然存在。

标签: laravel laravel-5 laravel-5.1


【解决方案1】:

如果您使用的是子域,请更改下面的这一行(配置/会话)

'domain' => null,

'domain' => '.yourdomain.com',

另外,如果您使用文件来存储会话

'driver' => env('SESSION_DRIVER', 'file'),

然后检查您是否拥有 storage/framework/sessions 目录的写权限。您也可以尝试更改数据库会话。

【讨论】:

  • 我尝试设置域但没有运气同样的问题
  • 我一直面临与 domain 相关的类似问题。我发现可能存在与服务器路径和符号链接相关的问题,其中实际路径不同且服务器上的代码位置不同。
  • 还有什么建议吗??
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-12-30
  • 2016-06-11
  • 1970-01-01
  • 2014-05-10
相关资源
最近更新 更多