Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php laravel Auth::check()失败_Php_Authentication_Laravel_Laravel 4_Laravel 5 - Fatal编程技术网

Php laravel Auth::check()失败

Php laravel Auth::check()失败,php,authentication,laravel,laravel-4,laravel-5,Php,Authentication,Laravel,Laravel 4,Laravel 5,成功验证:尝试()后,验证::检查()失败。我只是按照laracast.com教程做一个简单的身份验证。这是一个具体的教程。所以要么在4到5个版本之间做了一点小小的改变,要么我做错了什么 这是一个进行身份验证的函数,第二个函数进行检查。他们俩在同一个班 public function store() { $credentials = Input::only('user_displayname'); $credentials['password'] = Input::get('u

成功验证:尝试()后,验证::检查()失败。我只是按照laracast.com教程做一个简单的身份验证。这是一个具体的教程。所以要么在4到5个版本之间做了一点小小的改变,要么我做错了什么

这是一个进行身份验证的函数,第二个函数进行检查。他们俩在同一个班

public function store() 
{
    $credentials = Input::only('user_displayname');
    $credentials['password'] = Input::get('user_password');

    if (Auth::attempt($credentials))
    {
        return Auth::user();
    }

    return 'not logged';
}

public function status()
{
    return dd(Auth::check());
}
这是用户模型:

class User extends Eloquent implements UserInterface, RemindableInterface {

    use UserTrait, RemindableTrait;

    protected $table = 'user';

    protected $hidden = array('user_password', 'remember_token');

    protected $fillable = ['user_displayname', 'user_fname', 'user_lname', 'user_email',     'user_password'];

    public $errors;

    public static $rules = array(
        'user_displayname' => 'required|unique:user,user_displayName',
        'user_fname' => 'required',
        'user_lname' => 'required',
        'user_email' => 'required|unique:user,user_email',
        'user_password' => 'required'
    );


    public function isValid($data)
    {
        $validation = Validator::make($data, static::$rules);

        if ($validation->passes())  return true;

        $this->errors = $validation->messages();
    }

    public function getAuthPassword()
    {
        return $this->user_password;
    }

}
第二个问题。授权是使用laravel会话还是完全不同

编辑:

Auth是否有租约时间或类似的东西,只在时间到期后删除会话?此外,与计算机相比,我的数据库列“updated_at”和“created_at”给出了错误的时间。所以我在想,如果Auth正在检查某种时间,可能会因为错误的时间而总是失败

p.S已经在stackoverflow中查看了其他解决方案


谢谢

看起来像Auth::attemp()的参数;处于有效状态,请尝试使用此

public function store() 
{
    $credentials = array('user_displayname'=>Input::get('user_displayname'),
                         'user_password'=> Input::get('user_password'));
    if (Auth::attempt($credentials))
    {
        return Auth::user();
    }

    return 'not logged';
}

我想拉威尔有一只虫子。如果使用Auth::尝试验证您的凭据,则返回true并“销毁会话”。因此,我们重定向url并使用Auth::check()使其返回false。因为会话已被破坏,您丢失了要检查的数据。

我看到您已经从这一点开始了,但另一点是,laravel在保持数据库表的复数(用户)和模型单数(用户)方面非常严格。我看到您在模型中将表显式声明为用户,但可能会与laravel产生一些混淆。

看起来更像是会话问题。为了回答您的第二个问题-使用,身份验证使用Laravel会话。您的id列是
id
还是
user\u id
-从查看您的代码我猜您称之为
user\u id
?应该是
id
我开始认为会话配置可能有问题。除了会话生存期之外,还有其他设置可以测试吗?我试着改变“config/session.php”的生存期,没有影响。还尝试将用户id更改为id。也没有。您使用的会话驱动程序是什么?不确定我到底做了什么,但现在可以工作了。不,不是这样,您的示例是错误的。请阅读以下内容: