我无法使用signIn ... laravel

时间:2016-07-27 06:16:54

标签: php laravel login laravel-5.2

我无法登录,我的错误是

  

EloquentUserProvider.php第114行中的ErrorException:参数1已通过   到Illuminate \ Auth \ EloquentUserProvider :: validateCredentials()必须是   Illuminate \ Contracts \ Auth \ Authenticatable的实例,实例   App \ User,在C:\ wamp64 \ www \ Final中调用   Group \ vendor \ laravel \ framework \ src \ Illuminate \ Auth \ SessionGuard.php on   第385行并定义

我的代码:

我的控制器文件:

<?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();

     }


}

我的路线档案:

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

我的观看文件:

@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 

我的信息中心:

信息中心

1 个答案:

答案 0 :(得分:0)

您是否将Authenticatable特征添加到您的用户模型中?

use Illuminate\Contracts\Auth\Authenticatable;

class User extends Model {

    use Authenticatable;

}