简体   繁体   中英

Laravel Authenticate middleware flash message

In my auth middleware I have the following code:

        if (! Auth::user()->enabled) {
            Auth::logout();
            // $request->session()->flash('Test', 'Test');
            // return redirect()->route('site::home');

            return redirect()->route('site::home')->withFlash('Test');
        }

I'm trying to redirect the user back to the login page with a flash message but whenever I look into the session() there's no flash message.

What am I doing wrong? it feels like i've tried every variation of a flash message and none of it seems to work

return redirect()->route('site::home')->flash('This is a message!');

return \Redirect::back()->withWarning( 'Message you want show in View' );

试试这个

return redirect()->route('route_name')->with('custom_key', 'Custom Message');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM