0
votes

I noticed that my flash messages for some reason stopped showing.

Using the password reset route (/passwords/reset), I saw that the e-mail is being sent, however, the return after POST should display a message, something like "E-mail sent".

The point is that the message is not displayed, either in cases of failure or success.

resources/views/passwords/email.blade.php

@if (session('status'))
     <div class="alert alert-success">
          {{ session('status') }}
     </div>
@endif

vendor/laravel/framework/src/Illuminate/Foundation/Auth/SendsPasswordResetEmails.php

public function sendResetLinkEmail(Request $request)
{
    $this->validateEmail($request);

    $response = $this->broker()->sendResetLink(
        $this->credentials($request)
    );

    return $response == Password::RESET_LINK_SENT
                ? $this->sendResetLinkResponse($request, $response)
                : $this->sendResetLinkFailedResponse($request, $response);
}

...

protected function sendResetLinkResponse(Request $request, $response)
{
    return back()->with('status', trans($response));
}

EDIT 1 (2020-02-24): Can middleware interfere in this case?

Here is my app/Http/Kernel.php

protected $middleware = [
    \App\Http\Middleware\TrustProxies::class,
    \App\Http\Middleware\CheckForMaintenanceMode::class,
    \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
    \App\Http\Middleware\TrimStrings::class,
    \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
    \Illuminate\Session\Middleware\StartSession::class
];

protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        // \Illuminate\Session\Middleware\AuthenticateSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
    ],

    'api' => [
        'throttle:60,1',
        'bindings',
    ],
];

protected $routeMiddleware = [
    'auth' => \App\Http\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
    'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
    'can' => \Illuminate\Auth\Middleware\Authorize::class,
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
    'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
    'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
    'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
];

protected $middlewarePriority = [
    \Illuminate\Session\Middleware\StartSession::class,
    \Illuminate\View\Middleware\ShareErrorsFromSession::class,
    \App\Http\Middleware\Authenticate::class,
    \Illuminate\Session\Middleware\AuthenticateSession::class,
    \Illuminate\Routing\Middleware\SubstituteBindings::class,
    \Illuminate\Auth\Middleware\Authorize::class,
];

Could someone help me display flash messages again?

Thanks!

1
dump $response and see if the value is passedRegolith
$response is OK. The value is passwords.sentVitor
This $response should appear in my view, but for some reason Laravel is ignoring (or not saving) the flash messagesVitor

1 Answers

0
votes

In Your Controller

session()->flash('status', "Send Successfully");
return  redirect()->back();

In Your View

@if (session()->has('status'))
<div class="alert alert-success">{{ session()->get('status') }}</div>
@endif