【问题标题】:Laravel 5.5 Flash Message not working in blade file after redirect重定向后,Laravel 5.5 Flash 消息在刀片文件中不起作用
【发布时间】:2021-02-28 23:43:09
【问题描述】:

如果登录功能上的用户 is_active == 0,我想注销 我的代码

登录控制器.php

protected function authenticated(Request $request, $user)
{
    if($user->is_active == 0){
        Auth::logout();
        return redirect('/')->with(['errorMessage' => 'Your account is temporary blocked']);
    }
}

查看代码:

@if(session('errorMessage'))
    <span class="alert alert-danger">
        {{session('errorMessage')}}
    </span>
@endif

【问题讨论】:

  • 你能分享你的'/'路线吗?可能是因为您已登录而被重定向?
  • 不要检查会话变量,当您使用with() 传递密钥时,您可以将其用作本机变量,如$errorMessage
  • @JMoura 谢谢,这是我的错误,我重定向到'/' 路由,但是在到达'/' 路由后它重定向到默认路由'/login'
  • @Sysix 不,它是一个重定向,那些变量被闪现到会话中

标签: laravel session laravel-5


【解决方案1】:

我被重定向到“/”而不是“/login”

【讨论】:

  • 这正是你告诉它去的地方
  • 是的,我想重定向到登录页面而不是主页
猜你喜欢
  • 2021-03-20
  • 2014-04-18
  • 1970-01-01
  • 2019-01-31
  • 2016-08-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多