我对来自CI的Laravel和PHP 5.4很陌生。请原谅这个关于非常基本认证的愚蠢问题。Laravel 5.1基本身份验证(注册)不起作用
我是从the docs开始执行登录/注册(身份验证)。
我的迁移到位:
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('email')->unique();
$table->string('password', 60);
$table->string('first_name');
$table->string('last_name');
$table->rememberToken();
...
});
这里是我的config\auth.php
:
'driver' => 'eloquent',
'model' => App\User::class,
'table' => 'users',
'password' => [
'email' => 'emails.password',
'table' => 'password_resets',
'expire' => 60,
],
app\User.php
:
protected $table = 'users';
protected $fillable = ['first_name', 'last_name', 'email', 'password'];
protected $hidden = ['password', 'remember_token'];
app\Http\Controllers\Auth\AuthController.php
:
protected function validator(array $data) {
return Validator::make($data, [
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
protected function create(array $data) {
return User::create([
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
public function getLogin() {
return view('admin/login');
}
public function getRegister() {
return view('admin/register');
}
app\Http\routes.php
:
Route::get('admin/login', 'Auth\[email protected]');
Route::post('admin/login', 'Auth\[email protected]');
Route::get('admin/register', 'Auth\[email protected]');
Route::post('admin/register', 'Auth\[email protected]');
我的观点是否正确显示:
resources/views/admin/login.blade.php
resources/views/admin/register.blade.php
与形式:
<form action="/admin/login" method="POST">
<form action="/admin/register" method="POST">
这是我得到的。注册表格在提交时只是重定向到自己,没有错误。在users
数据库表中没有创建任何条目。
我错过了什么?
编辑
我不认为我需要添加一个postRegister()
,因为它是由AuthenticatesAndRegistersUsers
使用的RegistersUsers
性状由AuthController
使用已定义。
此外,不知道这是否有帮助,但我有2个虚拟主机指向同一个项目目录。
您检查应用程序日志?你可以在'storage/logs/laravel.log'中检查应用程序日志,确保你已经设置了error_reporting(E_ALL),并且检查服务器日志 –
考虑到你发布的方法,你应该添加你的'postRegister()'方法。 。或者你在使用默认值? 此外,请检查您的浏览器开发人员工具的网络选项卡,是否应告诉您从帖子请求中得到的回复,这应该暗示您为什么被重定向。 – Jeemusu
@GaneshGhalame我清除了laravel.log并重新提交了表单。日志中没有任何内容。 – Obay