php - Laravel Authentication fails with Auth::attempt -
i trying out jeffrey way authentication essentials tutorial on laravel 4, getting not same results. (https://www.youtube.com/watch?v=msewmvz4wp4)
when check dd($attempt), false, if logged in right credentials.
please tell me, going wrong. google lot, , people claim, password needs hashed, , hash it, before putting database, there must still error somewhere else.
here code: http://help.laravel.io/faff81e66d3672cb96d5ae2f8d0cccbf2e7f9052
also here important pieces of code:
my view form: create.blade.php
login
{{ form::open(array('route' => 'sessions.store')) }} <ul> <li> {{ form::label('email', 'email:')}} {{ form::text('email')}} </li> <li> {{ form::label('password', 'password:')}} {{ form::password('password')}} </li> <li> {{ form::submit() }} </li> </ul> {{ form::close() }}
and sessionscontroller.php
public function create() { // $users = user::all(); return view::make('sessions.create') ->with('users', $users); } /** * store newly created resource in storage. * * @return response */ public function store() { // validate $input = input::all(); $attempt = auth::attempt([ 'email' => $input['email'], 'password' => $input['password'] ]); dd($attempt); // if($attempt) { // return redirect::intended('/'); // } else { // return 'whatever bro'; // }; // dd('problem'); }
here screenshot of database: http://i.imgur.com/stgqu39.jpg
i expect boolean of dd($attempt) correct, if type in correct login credentials, shows false.
please can correct code :)
kind regards,
george
from screenshot of database can see not hashing password before storing in database. auth::attempt
function consider password hashed apply hash::make
given password , compare 1 stored in database.
to make code work, when registering user should use hash::make function before storing password:
$password = hash::make($input['password']); $user->password = $password; $user->save();
take on documentation http://laravel.com/docs/security
Comments
Post a Comment