2017-03-14 17 views
1

別のビューにログインしようとした人を認証に追加するにはどうすればよいですか?Laravelにログインする直前にリダイレクトする5.4

私はそれはまだ私はそれだけでログインする前に「/ AUTH /」ビューを表示するためにしようとしている、そしてそれはビューを示していますがAuthenticateUsers.php

public function login(Request $request) 
    { 
     $this->validateLogin($request); 

     // If the class is using the ThrottlesLogins trait, we can automatically throttle 
     // the login attempts for this application. We'll key this by the username and 
     // the IP address of the client making these requests into this application. 
     if ($this->hasTooManyLoginAttempts($request)) { 
      $this->fireLockoutEvent($request); 

      return $this->sendLockoutResponse($request); 
     } 

     if ($this->attemptLogin($request)) { 
      //return $this->sendLoginResponse($request); 
      return redirect('/auth/'.Auth::id()); 
     } 

     // If the login attempt was unsuccessful we will increment the number of attempts 
     // to login and redirect the user back to the login form. Of course, when this 
     // user surpasses their maximum number of attempts they will get locked out. 
     $this->incrementLoginAttempts($request); 

     return $this->sendFailedLoginResponse($request); 
    } 

でこれを試してみましたログ私の中であなたは、あなたのリダイレクトを設定し

+0

あなたのルートから認証ミドルウェアを削除しようとしましたか? – Onix

+0

私のルートには認証ミドルウェアがありません。 'Route :: get( '/ auth/{id}'、 'AuthController @ index'); ' –

+0

あなたが最初にアクセスするルートを表示できますか? – Onix

答えて

0

直後attemptLogin()

if ($this->attemptLogin($request)) { 
    return redirect('/auth/'.Auth::id()); 
} 

何このコードの言うことは「、ということであるならば、ユーザーのsu '/ auth/$ id'にリダイレクトしてください。だからあなたがリダイレクトされたときにあなたは常にログインしています。

ちょうどそのライン

return redirect('/auth/'.Auth::id()); 
if ($this->attemptLogin($request)) { 
    //do stuff 
} 

しかし、あなたは常にあなたがログインに到達する前に返すので、今、あなたは、ログインすることができないだろう前に置きますリダイレクトを。

手動認証をお勧めします。あなたはここに助ける見つけることができます: http://laravel-recipes.com/recipes/221/manually-logging-a-user-in

http://tutsnare.com/authentication-with-laravel-5/

+0

私は試行ログオンの前にリダイレクトを置く場合、私は最初にログインを押すとリダイレクトされません、私はユーザーをリダイレクトできるようにしたいとき彼らはログインをクリックして、認証フォームを表示し、正しく記入された後にログインします。 –

+0

いいえ、できません。 'attempLogin()'を渡すと、すでに接続されています。ごめんなさい。 – EddyTheDove

+0

これは変ですが、これを行う方法はありませんか? –

関連する問題