php - Login authentication fails in laravel 4 -


in laravel4,i have written following code in routes redirect me login page. have googled , found on stack overflow , tried solutions not succeeded.i sure silly mistake kindly track out.thank you

routes:

route::post('login', function ()     {             $user = array(         'username' => input::get('username'),         'password' => hash::make(input::get('password'))     );             /* store entered username , password in array named 'user' */             print_r($user);              if (auth::attempt($user))              {                 return redirect::route('home')->with('flash_notice', 'you logged in.');                 /* authentication success!!..redirect user home page */             }             else             {                 return redirect::route('login')                     ->with('flash_error', 'your username/password combination incorrect.')->withinput();                             /* authentication failure!! lets go login page */             }     }); 

user model:

<?php  use illuminate\auth\userinterface; use illuminate\auth\reminders\remindableinterface;  class user extends eloquent implements userinterface, remindableinterface  {     /**      * database table used model.      *      * @var string      */     protected $table = 'users';      // public $timestamps = false;      /**      * primary key of table.      *      * @var string      */     protected $primarykey = 'id';      /**      * attributes excluded model's json form.      *      * @var array      */     protected $hidden = array('password');      /**      * password user.      *      * @return string      */     public function getauthpassword()     {         return $this->password;     }      /**      * e-mail address password reminders sent.      *      * @return string      */     public function getreminderemail()     {         return $this->email;     }    /**  * unique identifier user.  *  * @return mixed  */ public function getauthidentifier() {     return $this->getkey(); }  /**  * password user.  *  * @return string  */ 

}

user seeder:

<?php class userseeder extends seeder {      public function run()     {          db::table('users')->delete();         return array('table'=>'users',         array(                 'username' => 'admin',                 'password' => 'admin'          ),         );     } } 

when ask auth class attempt login, pass in username , pass is. if method, first hash password make secure , match database entry. when storing it, present implementation, not hashed.

as suggested above, should make change in seeder:

array(     'username' => 'admin',     'password' => hash::make('password') ), 

although not sure if way using seeder correct syntax, if works, hash password there.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -