Laravel 5.5 Auth status in session is lost after redirect to custom url (instead of home)
I have a fresh Laravel 5.5 LTS project and I've published the auth feature using php artisan make:auth and tested it, it was all working fine. I.e. after successful register/login, I've got the status in session showing the message.
By default, after successful register/login, it redirects you to /home but I wanted a different route; i.e. /account - so I made the following controller:
app/Http/Controllers/Account/HomeController.php
<?php
namespace App\Http\Controllers\Account;
use App\Http\Controllers\Controller;
class HomeController extends Controller
{
/**
* Show the account home page.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return view('account.home');
}
}
and Created the following resources/views/account/home.blade.php view with:
@extends('layouts.master')
@section('content')
@if (session('status'))
<div class="alert alert-success">
{{ session('status') }}
</div>
@endif
<!-- Inner Wrapper Start -->
<section class="inner-wrapper call-back small-section">
<div class="container">
<p>Welcome to My Account page</p>
</div>
</section>
<!-- Inner Wrapper End -->
@endsection
and updated the routes/web.php like this:
// Authentication routes
Auth::routes();
// Account routes
Route::group(['prefix' => 'account', 'namespace' => 'Account', 'middleware' => 'auth'], function()
{
Route::get('/', 'HomeController@index')->name('home');
});
and finally updated app/Http/Controllers/Auth/LoginController.php with the new direct url:
protected $redirectTo = '/account';
Now when I register or login within my app, it's correctly redirecting me to /account url, but I am no longer getting the status from the session - as if it's getting lost.
Any idea what might be wrong?
Please or to participate in this conversation.