пользователь: [email protected], пароль: 123456
Когда я прохожу процесс регистрации, все работает как положено, и запись внесено в таблицу пользователей базы данных
После завершения я перенаправляю пользователя на панель управления.
public function postCreate(){
//Rules
$rules = array(
'fname'=>'required|alpha|min:2',
'lname'=>'required|alpha|min:2',
'email'=>'required|email|unique:users',
'password'=>'required|alpha_num|between:6,12|confirmed',
'password_confirmation'=>'required|alpha_num|between:6,12'
);
$validator = Validator::make(Input::all(), $rules);
if($validator->passes()){
//Save in DB - Success
$user = new User;
$user->fname = Input::get('fname'); //Get the details of form
$user->lname = Input::get('lname');
$user->email = Input::get('email');
$user->password = Hash::make(Input::get('password'));//Encrypt the password
$user->save();
return Redirect::to('/books')->with('Thank you for Registering!');
}else{
//Display error - Failed
return Redirect::to('/')->with('message', 'The Following Errors occurred')->withErrors($validator)->withInput();
}
}
Затем я возвращаюсь на целевую страницу и пытаюсь войти в систему, используя указанные выше учетные данные, но мне постоянно сообщают, что Auth::attempt() не работает, поэтому мой пользователь не может войдите в приложение.
public function login(){
if(Auth::attempt(array('email'=>Input::get('email'), 'password'=>Input::get('password')))){
//Login Success
echo "Success"; die();
return Redirect::to('/books');
}else{
//Login failed
echo "Fail"; die();
return Redirect::to('/')->with('message', 'Your username/password combination was incorrect')->withInput();
}
}
Кто-нибудь знает, почему это происходит? Это схема для таблицы моих пользователей:
Schema::create('users', function($table){
$table->increments('id');
$table->integer('type')->unsigned();
$table->string('fname', 255);
$table->string('lname', 255);
$table->string('email')->unique();
$table->string('password', 60);
$table->string('school', 255);
$table->string('address_1', 255);
$table->string('address_2', 255);
$table->string('address_3', 255);
$table->string('address_4', 255);
$table->string('remember_token', 100);
$table->timestamps();
});
Любая помощь приветствуется.
'Просмотр для входа':
Home page
Register
- @foreach($errors->all() as $error)
- {{ $error }}
@endforeach
First Name
Last Name
Password
Confirm Password
Login
Password
Подробнее здесь: https://stackoverflow.com/questions/253 ... -each-time