版本5.1的Laravel身份验证问题

时间:2016-06-03 06:29:50

标签: laravel laravel-5 laravel-5.1

我有验证问题。在版本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';


}

1 个答案:

答案 0 :(得分:0)

如果您正在使用子域,请在下面更改此行(config / session)

'domain' => null,

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

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

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

然后检查您是否具有存储/框架/会话目录的写入权限。您也可以尝试更改数据库会话。