2
votes

I am new in Larave and I made a login form that not working, I searched a lot about this problem and I found these questions and answers that not working for me:

  1. Question 1
  2. Question 2
  3. Question 3

I read these 3 questions and again not working:

This is my users table:

id | username | password | remember_token | created_at | updated_at

1 | [email protected]| testpass1

This is my User Model:

    <?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');
}

This is my route:

Route::group(array('prefix'=>'admin','before'=>'Auth'),function(){
    Route::resource('posts','AdminPostsController', array('except'=>array('show')));
});

This is Filter(Auth):

 Route::filter('Auth', function()
{
    if (Auth::guest())
    {
        if (Request::ajax())
        {
            return Response::make('Unauthorized', 401);
        }
        else
        {
            return Redirect::guest('admin/login');
        }
    }
});

and this is AdminAuthController that route send data from login to 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')     )));
   }

This is what Laravel return in browser: http://i.stack.imgur.com/9cq61.png

1
@MattBurrow Yes I didn't see that. Thanks - user4434835

1 Answers

1
votes

The password in your table needs to be hashed!

You can use Hash::make('password') to generate a hash of the password. If you want to update your db manually in development you can use artisan tinker to quickly generate a hash:

php artisan tinker
> echo Hash::make('your-secret-password');

Copy the output and update the password field in your db.

Note the db field needs to be at least 60 characters long