【发布时间】:2015-03-07 15:03:00
【问题描述】:
我是 Larave 的新手,我制作了一个不起作用的登录表单,我搜索了很多关于这个问题的问题,我发现这些问题和答案对我不起作用:
我阅读了这 3 个问题,但仍然无法正常工作:
这是我的用户表:
标识 |用户名 |密码 |记住令牌 | created_at |更新时间
1 | e@so.com|测试通过1
这是我的用户模型:
<?php
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
class User extends Eloquent implements UserInterface, RemindableInterface {
use UserTrait, RemindableTrait;
public static $auth_rules=[
'email'=>'required|email',
'password'=>'required|between:3,18'
];
protected $hidden = array('password', 'remember_token');
}
这是我的路线:
Route::group(array('prefix'=>'admin','before'=>'Auth'),function(){
Route::resource('posts','AdminPostsController', array('except'=>array('show')));
});
这是过滤器(Auth):
Route::filter('Auth', function()
{
if (Auth::guest())
{
if (Request::ajax())
{
return Response::make('Unauthorized', 401);
}
else
{
return Redirect::guest('admin/login');
}
}
});
这是 AdminAuthController,它将数据从登录发送到 AdminAuthController@postLogin:
//This is postLogin method:
public function postLogin(){
//Showing username and password
echo 'Username:'.Input::get('email').'<br/>';
echo 'Password:'.Input::get('password').'<br />';
//If username and password: return true
dd(Auth::attempt(array('username'=>Input::get('email'),'password'=>Input::get('password') )));
}
这是 Laravel 在浏览器中返回的内容: http://i.stack.imgur.com/9cq61.png
【问题讨论】:
-
@MattBurrow 是的,我没有看到。谢谢
标签: php authentication laravel