无法通过Auth :: attempt方法登录

时间:2017-10-15 01:34:58

标签: php laravel

Ilearn laravel几乎在我的问题上需要一些帮助 我需要登录,但我不能>它总是给我假  任何帮助!!我不知道bcrypt中的问题还是什么?

Auth :: attempt()总是为什么错?

    <?php


      namespace App\Http\Controllers;
      use Illuminate\Http\Request;

      use Illuminate\Support\Facades\Auth;
      use App\User;

      class UserController extends Controller
      {
        public function getBoard(){

          return view('dashboard');
        }

        //sin up function

        public function postSignUp(Request $request)
       {

             $email = $request['email'];
             $First_Name = $request['First_Name'];
             $password = \Hash::make($request['password']);
             $user = new User();
             $user->email = $email;
             $user->First_Name = $First_Name;
             $user->password = $password;
             $user->save();

             Auth::login($user);

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

      }    //sin in function
      public function postSignIn(Request $request)
    {
      $email =  $request['email'];
      $password = $request['password'];

      if (Auth::attempt(['email' => $email,
       'password' => "123" ])) {
          return redirect()->route('dashboard');
      }
      echo  "not working";
    }
      }

1 个答案:

答案 0 :(得分:0)

我不明白你为什么要使用&#34; 123&#34;作为密码传递给Auth ::尝试......你不应该这样做吗?

public function postSignIn(Request $request)
 {
   $email =  $request['email'];
   $password = $request['password'];

   if (Auth::attempt(['email' => $email, 'password' => $password ])) {
      return redirect()->route('dashboard');
   }
   echo  "not working";
 }