如何在laravel中处理被阻止的用户

问题描述 投票:1回答:1

我需要帮助。你可以指导我如何向被阻止的用户显示他的帐户被阻止的消息。我只是让他发布页面。但我想向他展示一些消息,表明您的帐户已被屏蔽,或者我们在验证消息中做了类似的事情。请简要指导。

公共功能登录(请求$请求){$ username = $ request-> username;

     $user = User::where('username',$username)->first();
  //  return $user;

   // return $user->id;
    if($user != null){

        $active = Activation::whereUserId($user->id)->first();

        if($active->completed==0){
        return redirect('/posts');
        }
laravel authentication block
1个回答
0
投票

你需要使用session。一种方法:

return redirect('posts')->with('error', 'Your account is blocked');

在重定向后的视图中:

@if (session('error'))
    {{ session('error') }}
@endif

如果您不想重定向用户,只需将变量传递到视图中:

return view('login.form', ['notActivated' => $active->completed === 0])

在视图中:

@if ($notActivated)
    Your account is blocked
@endif
© www.soinside.com 2019 - 2024. All rights reserved.