mardi 22 décembre 2015

How to validate credentials in laravel 5 for loggin in features?

    I am new to laravel and i am using tutorial for wep app.Tutorial use laravel 4 whereas i am using laravel 5. I solved register issue but when i sat down to test for login following errors shown up:
    ErrorException in EloquentUserProvider.php line 111: Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\user given, called in C:\Users\Pujan\Desktop\projectlaravel\vendor\laravel\framework\src\Illuminate\Auth\Guard.php on line 390 and defined.

This problem giving lots of headache and i aint able to figure out both problem and solution.What actually means credentials. I know laravel 5 has inbuilt login features but couldnt use it so i tried out different ways but this problem out of my focus. My usercontroller is:

    namespace App\Http\Controllers;

    use Illuminate\Http\Request;

    use App\Http\Requests;
    use App\Http\Controllers\Controller;
    use View;

    use App\user;
    use Input;
    use App\Http\Requests\YourFormRequest;
    use Auth;
    //use Illuminate\Support\Facades\Auth;

    class UserController extends Controller
    {

         public $restful = true;

        public function index()
        {

            return View::make('users.new')->with('title', 'Make it snappy Q&A - Register');
        }


    public function create(YourFormRequest $request)
    {
        User::create($request->all());

        return redirect('/')->with('message','Thanks for registering!');
    }
    public function getlogin()
    {
       // return \Auth::user();
        return View::make('users.login')->with('title','Make it snappy Q&A - Login ');
    }
    public function createlogin(){
        $user = array(
            'username'=>Input::get('username'),
            'password'=>Input::get('password')
            );
        if (Auth::attempt($user))
        {
            return redirect('/')->with('message','You are logged in:');
        }else{
            return redirect('login')
            ->with('message','Your username or password are incorrect pls chk it out')
            ->with_input();
        }
    }
I have my routes:
Route::get('/','Questions@index');
Route::get('register','UserController@index');
Rou`enter code here`te::get('login','UserController@getlogin');
Route::post('register','UserController@create');
Route::post('login','UserController@createlogin');

my login layout working properly but as i try to login above errors shown up.I think this error belongs to inbuilt laravel 5 features but i couldnot able to match the setting inbuilt and my created login functionality.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire