2013-09-19 9 views
0

Я пытаюсь использовать класс Autar Laravel, но метод всегда возвращает false. Вот мой код:Laravel 4 Auth :: попытка() issue

Контроллер:

public function postLogin() 
    { 
     // Declare the rules for the form validation. 
     // 
     $rules = array(
      'email' => 'Required|Email', 
      'password' => 'Required' 
     ); 

     // Get all the inputs. 
     // 
     $email = Input::get('email'); 
     $password = Input::get('password'); 
     // Validate the inputs. 
     // 
     $validator = Validator::make(Input::all(), $rules); 

     // Check if the form validates with success. 
     // 
     if ($validator->passes()) 
     { 
        //echo $password; displays test 
      // Try to log the user in. 
      // 
      if (Auth::attempt(array('email' => $email, 'password' => $password))) 
      { 


       // Redirect to the users page. 
       // 
       return Redirect::to('account')->with('success', 'You have logged in successfully'); 
      } 
      else 
      { 
       // Redirect to the login page. 
       // 
       return Redirect::to('account/login')->with('error', 'Email/password invalid.'); 
      } 
     } 

     // Something went wrong. 
     // 
     return Redirect::to('account/login')->withErrors($validator->getMessageBag()); 
    } 

Seeder.php

публичную функцию запуска() { DB :: таблица ('пользователи') -> Удалить();

$users = array(
    array(
     'email'  => '[email protected]', 
     'password' => Hash::make('test'), 
    'first_name' => 'John', 
    'last_name' => 'Doe', 
     'created_at' => new DateTime, 
     'updated_at' => new DateTime, 
    ) 
); 

DB::table('users')->insert($users); 

}

+0

Вы уверены, что получаете $ email и пароль? и проверьте свою базу данных с помощью phpmyadmin. – devo

+0

Я их получаю! –

+0

Вы получаете учетную запись/логин с ошибками проверки или недействительными по электронной почте/паролю? – devo

ответ

1

Это будет из-за ошибки рамочным. Поэтому попробуйте обновить его.

composer update 

Или

php composer.phar update 
1

В файле конфигурации/auth.php попробуйте изменить от 'водителя' => 'красноречивый' на 'водитель' => 'базы данных'.

Смежные вопросы