1
votes

i'm unable to SignIn , my error is

ErrorException in EloquentUserProvider.php line 114: 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:\wamp64\www\Final Group\vendor\laravel\framework\src\Illuminate\Auth\SessionGuard.php on line 385 and defined

my code:

my controller file :

<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Input;

//use Illuminate\Support\Facades\Flash;
use InvalidConfirmationCodeException;

use Flash;

//use Mail;

use App\User;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Auth;

use Illuminate\Support\Facades\Mail;

use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;


class UserController extends Controller

{

    public function getDashboard()


       {

             return view('dashboard');
       }


     public function postSignUp(Request $request)
     {


       $email = $request['email'];
       $first_name = $request['first_name'];
       $password = bcrypt($request['password']);



        $user = new User();
        $user->email =$email;
        $user->first_name = $first_name;
        $user->password = $password;


        $user->save();




        return redirect()->route('dashboard');

        Auth::login($user);


     }

     public function postSignIn(Request $request)
     {

        if (Auth::attempt(['email' => $request['email'], 'password' => $request['password']]))  {

            return redirect()->route('dashboard');
        }

               return redirect()->back();

     }


}

my route file:

<?php



/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('welcome');
});

            Route::post('/signup',[
                'uses' => 'UserController@postSignUp',
                'as'   => 'signup'


                ]);

            Route::post('/signin',[
                'uses' => 'UserController@postSignIn',
                'as'   => 'signin'


                ]);

            Route::get('/dashboard',[
                 'uses' => 'UserController@getDashboard',
                 'as'   => 'dashboard'
                ]);


//Route::auth();

//Route::get('/home', 'HomeController@index');

my view file :

@extends('layouts.master')

@section('title')


Welcome


@endsection

@section('content')


<div class="row">

   <div class="col-md-6">

       <h3>Sign Up</h3>

       <form action="{{route('signup')}}" method="post">

          <div class="form-group">

              <label for="email">Your Email</label>

              <input  class="form-control" type="text" name="email" id="email">

          </div>

          <div class="form-group">

              <label for="first_name">Your Name</label>

              <input  class="form-control" type="text" name="first_name" id="first_name">

          </div>

          <div class="form-group">

              <label for="password">Your Password</label>

              <input  class="form-control" type="password" name="password" id="password">

          </div>  

              <button type="submit" class="btn btn-primary">Submit</button>
              <input type="hidden" name="_token" value="{{Session::token()}}">

       </form>




   </div>


          <div class="col-md-6">

       <form action="{{route('signin')}}" method="post">

             <h3>Sign In </h3>

          <div class="form-group">

              <label for="email">Your Email</label>

              <input  class="form-control" type="text" name="email" id="email">

          </div>



          <div class="form-group">

              <label for="password">Your Password</label>

              <input  class="form-control" type="password" name="password" id="password">

          </div>  

              <button type="submit" class="btn btn-primary">Submit</button>
              <input type="hidden" name="_token" value="{{Session::token()}}">

       </form>


   </div>


</div>

@endsection 

my dashboard :

Dashboard

1

1 Answers

0
votes

Did you add the Authenticatable trait to your User model like this?

use Illuminate\Contracts\Auth\Authenticatable;

class User extends Model {

    use Authenticatable;

}