当前位置:网站首页>Laravel 8 realizes auth login

Laravel 8 realizes auth login

2022-06-24 14:27:00 s_ Canned ice

notes : stay Use auth Login time , The password must be encrypted in the database , and

auth Login must use username and password. Encryption password can use the function bcrypt() To encrypt .

1. The background controller performs authentication login .

// Receive the transmitted value 
        $username = $request->post('username');
        $password = $request->post('password');
        $catch = $request->post('catch');

        // Verify by verifier 
        $validatedData = $request->validate([
            'username' => 'required',
            'password' => 'required',

        ]);
        // Use auth Do login verification 
        $res = Auth::attempt($validatedData);
        if ($res) {
            // Log in successfully and jump to the list page 
            return redirect('show');
        } else {
            echo " Login failed ";
        }

2. Configure the login model .

3. In our laravel Make some configuration changes in the configuration file .

Introduce the model we just set up .

 

Finally, perform login test

原网站

版权声明
本文为[s_ Canned ice]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206241244453569.html