title: How to redirect the user to the same page after login?
body: <p>I have a login.blade.php, so when user accesses "project.test/login" he has an email and password fields to login.</p>
  
  <p>I also have a header.blade.php that has the main menu, in this main menu there is a link "Create congress". If the user is not authenticated and click in "Create congress" he should not have acess to the page, he should be redirected to the login page. After login with success he should be redirected to the "Create congress" page.</p>
  
  <p>This is working fine.</p>
  
  <p><strong>Doubt:</strong></p>
  
  <p>But then I also have a "registration.blade.php" when user accesses "<a href="http://project.test/congress/1/congresstest/registration" rel="nofollow noreferrer">http://project.test/congress/1/congresstest/registration</a>". When user accesses this page if is not authenticated it appears this this message:</p>
  
  <pre><code>@if(!\Auth::check())
      &lt;div class="alert alert-info" role="alert"&gt;
          &lt;span&gt;
              Already have an account? 
              &lt;a data-toggle="modal" 
              data-target=".bd-example-modal-lg" 
              class="font-weight-bold" href=""&gt;Login.&lt;/a&gt;
          &lt;/span&gt;
      &lt;/div&gt;
  @endif
  </code></pre>
  
  <p>If user clicks in Login, it appears a modal so the user can insert the email and password and if login with success the modal should close and he should be redirected to the same registration page.</p>
  
  <p>The issue is that if the user logins with success in this page "<a href="http://project.test/congress/1/congresstest/registration" rel="nofollow noreferrer">http://project.test/congress/1/congresstest/registration</a>" with the form in the modal he is redirected to the "Create  congress" page instead of staying in the registration page. Do you know how to correct this issue? </p>
  
  <p><strong>Relevant code for the question:</strong></p>
  
  <p><strong>Login.blade.php:</strong></p>
  
  <pre><code>&lt;form class="clearfix" method="POST" action="{{ route('login') }}"&gt;
  {{ csrf_field() }}
  &lt;div class="form-group col-12 px-0"&gt;
      &lt;label for="inputEmail4"&gt;Email&lt;/label&gt;
      &lt;input type="email" class="form-control" value="{{ old('email') }}" name="email" required autofocus&gt;
  &lt;/div&gt;
  &lt;div class="form-group col-12 px-0"&gt;
      &lt;label for="inputEmail4"&gt;Password&lt;/label&gt;
      &lt;input type="password" class="form-control" name="password" required&gt;
  &lt;/div&gt;
  &lt;button type="submit"&gt;Login&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>LoginController:</strong></p>
  
  <pre><code>class LoginController extends Controller
  {
      use AuthenticatesUsers;
      protected $redirectTo = '/home';
  
      public function __construct()
      {
          $this-&gt;middleware('guest')-&gt;except('logout');
      }
  
      protected function authenticated(Request $request, $user)
      {
          return redirect()-&gt;intended($this-&gt;redirectTo);
      }
  }
  </code></pre>
  
  <p><strong>header.blade.php</strong> with the main menu where there is a link to create a new congress:</p>
  
  <pre><code>&lt;li&gt;
      &lt;a href="{!! route('congress.create') !!}"&gt; Create Congress &lt;/a&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p><strong>Modal with the login form:</strong></p>
  
  <pre><code>&lt;div class="modal fade bd-example-modal-lg" id="modal2" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"&gt;
    &lt;div class="modal-dialog modal-sm"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
          &lt;h5 class="modal-title" id="exampleModalLabel"&gt;Login&lt;/h5&gt;
          &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
            &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
          &lt;/button&gt;
        &lt;/div&gt;
        &lt;div class="modal-body"&gt;
          &lt;div class="container"&gt;
            &lt;div class="row"&gt;
              &lt;form class="clearfix" method="POST" action="{{ route('login') }}"&gt;
                {{ csrf_field() }}
  
                &lt;div class="form-group col-12 px-0"&gt;
                  &lt;label for="inputEmail4"&gt;Email&lt;/label&gt;
                  &lt;input type="email" class="form-control" value="{{ old('email') }}" name="email" required autofocus&gt;
                &lt;/div&gt;
  
                &lt;div class="form-group col-12 px-0"&gt;
                  &lt;label for="inputEmail4"
                         class="text-heading font-weight-semi-bold"&gt;Password
                    &lt;a href="{{ route('password.request') }}" class="text-gray ml-1" style="text-decoration: underline"&gt;
                      &lt;small&gt;Recover Password&lt;/small&gt;&lt;/a&gt; &lt;/label&gt;
                  &lt;input type="password" class="form-control" name="password" required&gt;
                &lt;/div&gt;
  
  
                &lt;button type="submit" class="btn btn-primary btn d-block w-100"&gt;Login&lt;/button&gt;
  
              &lt;/form&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="modal-footer"&gt;
          &lt;button type="button" class="btn btn-primary" data-dismiss="modal"&gt;Close&lt;/button&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>Routes:</p>
  
  <pre><code>Route::get('/', [
      'uses' =&gt; 'FrontController@index',
      'as'   =&gt;'index'
  ]);
  
  // Auth routes
  Auth::routes();
  
  
  Route::get('auth/{provider}/callback', [
      'uses' =&gt; 'OauthController@handleProviderCallback',
  ]);
  
  // route to the registration page
  Route::post('/congress/{id}/{slug?}/registration', [
      'uses' =&gt; 'RegistrationController@storeQuantity',
      'as'   =&gt;'congresses.registration'
  ]);
  
   Route::group(['prefix' =&gt; '', 'middleware' =&gt; 'auth'], function(){
  
  // route to the create congress page
    Route::get('/congress/create', [
          'uses' =&gt; 'CongressController@create',
          'as'   =&gt; 'congress.create'
      ]);
    }
  </code></pre>
  
  <p><strong>CongressController:</strong></p>
  
  <pre><code>class CongressController extends Controller
  {
  
      public function create()
      {
          return view('congresses.create')-&gt;with('categories', Category::all());
      }
  }
  </code></pre>