为什么我无法使用此代码登录应用程序的第一个用户,这可能是什么原因

兽王

我可以像这样突出显示一个登录第二个用户

在此处输入图片说明

但是第一个,我无法登录,这是我的代码

public function postLogin(Request $request)
    {
        // -> Validate the request. 
        $this->validate(request(), [
            'pin' => 'required|string',
            'password' => 'required|string',
        ]);

        $pin = request()->get('pin');

        $field = filter_var(request()->get('pin'), FILTER_VALIDATE_EMAIL) ? 'email' : 'username';       

        $remember_me = request()->get('remember');

        $password = request()->get('password');

        $user = User::where("${field}",'=',$pin)->first();

        // dd($user);

        if ( is_null($user->confirmed_at) || $user->status === "0") {
            return redirect()->back()->with('flash-message','The account you tried to login was either not yet confirmed by you or activated by one of our admins.');
        }

        else {
            if (Auth::attempt([$field => $pin ,'password' => $password])){
                // dd(auth()->user()->role_id);
                switch(auth()->user()->role_id){
                    /*the roles would be determined*/   
                    case 1 : return redirect()->route("admin.dashboard");
                    case 2 : return redirect()->route("admin.dashboard");
                    case 3 : return redirect()->to('/');            
                }
            }
        }
    }

登录后以及dd的结果时,我都会出现白屏

        $user = User::where("${field}",'=',$pin)->first();

我明白了 在此处输入图片说明

状态字段是一个enum字段

在此处输入图片说明

这是扩展

在此处输入图片说明

弗拉丹

您的密码似乎不正确,因为您不处理这种情况。那将解释黑屏。尝试添加类似这样的东西,看看它是否进入那里。

if (Auth::attempt([$field => $pin ,'password' => $password])){
    // dd(auth()->user()->role_id);
    switch(auth()->user()->role_id){
        /*the roles would be determined*/
        case 1 : return redirect()->route("admin.dashboard");
        case 2 : return redirect()->route("admin.dashboard");
        case 3 : return redirect()->to('/');
    }
} else {
    dd('Auth failed!');
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

从Firebase Firestore获取数据时,我的SwiftUI应用程序崩溃并出现错误。这可能是什么原因造成的?

我的登录表单无法在Android中使用。可能是什么原因?

Node.js-Socketio无法与https服务器一起使用,这可能是什么原因?

测试android应用程序时无法更改某些手机上的图标。可能是什么原因?

Internet Explorer 11中的第一个HTTPS连接速度很慢,这可能是什么?

只能使用https访问网站,这可能是什么原因造成的?

网页加载后跳到底部,不知道为什么,这可能是什么原因?

GC消耗了三个小时来减少1.2GB的堆,这可能是什么原因?

我认为此代码容易受到攻击。可能是什么原因?

绘图函数仅在此数据框中绘制一个数量。可能是什么原因?

Firefox 中文本区域闪烁,高度 = 继承。这可能是什么原因?

找不到名称“控制台”。这可能是什么原因?

代理不适用于 PhantomJS。这可能是什么原因?

FFMPEG的持续时间规范无效-这可能是什么原因?

为什么应用程序不在angular js中显示第一个视图

我的第一个Android应用程序有什么问题?

是什么原因导致访问非空列表中的第一个元素时出现IndexError?

Firebase:为什么我的代码只使用集合中的第一个文档?

Nodejs代码无法在Windows10上构建,但可以在MacOS上运行。可能是什么原因?

第一个代码片段与第二个和第三个代码输出不同的可能原因是什么?

JMXterm命令从终端手动运行,而不是从脚本手动运行,这可能是什么原因?

在本地运行python脚本有效,但是通过travis-ci失败,这可能是什么原因?

Laravel Project在XAMPP htdocs文件夹中不起作用。这可能是什么原因?

是什么原因导致无法识别安装的应用程序?

是什么原因导致“ Uncaught SyntaxError:意外令牌”。在我的应用程序中?

在对C到C#使用P / Invoke并将C struct混搭到C#时,会生成AccessViolationException,这可能是什么原因?

运行后我无法使用 Flutter 运行我的第一个应用程序我收到此错误

编写我的第一个闪亮的应用程序,如何按选定的变量绘图,为什么这个脚本不起作用?

为什么我会在 Django 教程“编写第一个 Django 应用程序”的第 4 部分中收到 404 错误