php – Laravel 4 Auth:尝试不工作
发布时间:2020-12-14 19:47:13 所属栏目:大数据 来源:网络整理
导读:我正在努力使用Laravel 4 Auth :: attempt方法,按照正确的文档,阅读几个SO线程,但我仍然无法让它工作. $userData = array('email' = 'admin@admin.com','password' = 'admin');if(Auth::attempt($userData)){ // redirect}else{ echo 'Invalid';} 并且每次都
我正在努力使用Laravel 4 Auth :: attempt方法,按照正确的文档,阅读几个SO线程,但我仍然无法让它工作.
$userData = array('email' => 'admin@admin.com','password' => 'admin'); if(Auth::attempt($userData)){ // redirect } else{ echo 'Invalid'; } 并且每次都返回Invalid 现在我不确定究竟是什么原因. 在我的config / auth.php中,我有以下内容 <?php return array( /* |-------------------------------------------------------------------------- | Default Authentication Driver |-------------------------------------------------------------------------- | | This option controls the authentication driver that will be utilized. | This drivers manages the retrieval and authentication of the users | attempting to get access to protected areas of your application. | | Supported: "database","eloquent" | */ 'driver' => 'eloquent',/* |-------------------------------------------------------------------------- | Authentication Model |-------------------------------------------------------------------------- | | When using the "Eloquent" authentication driver,we need to know which | Eloquent model should be used to retrieve your users. Of course,it | is often just the "User" model but you may use whatever you like. | */ 'model' => 'User',/* |-------------------------------------------------------------------------- | Authentication Table |-------------------------------------------------------------------------- | | When using the "Database" authentication driver,we need to know which | table should be used to retrieve your users. We have chosen a basic | default value but you may easily change it to any table you like. | */ 'table' => 'users',/* |-------------------------------------------------------------------------- | Password Reminder Settings |-------------------------------------------------------------------------- | | Here you may set the settings for password reminders,including a view | that should be used as your password reminder e-mail. You will also | be able to set the name of the table that holds the reset tokens. | */ 'reminder' => array( 'email' => 'emails.auth.reminder','table' => 'password_reminders',),); ?>
确保数据库中的密码字段有64个字符的空间. VARCHAR(64)
哈希需要64个字符,如果您的哈希密码在插入时被截断(因此无法正确验证密码),您将不会从laravel中获得错误. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |