如何在 Laravel 5.2 中使用多重身份验证
问题描述
有谁知道如何在 laravel 5.2 中使用多重身份验证!
我想使用它但我不知道如何使用?
有没有人有设置多重身份验证的教程或项目?
Does anyone know how to use multi authenticate in laravel 5.2 !
I want to use It but I don't know how ?
does anyone has a tutorial or project setting up multi authentication?
推荐答案
你需要两个表 users
和 admins
运行以下命令以创建内置身份验证
You need two tables users
and admins
Run command following command to create built in auth
两个模型用户(已经存在)和管理员
Two models Users(Already exist) and Admin
现在打开 config/auth.php 并进行以下更改
Now open config/auth.php and make the following changes
创建一个新的中间件 RedirectIfNotAdmin
Kernel.php 中的变化
Changes in Kernel.php
创建一个新文件夹Http/Controller/Adminauth并从Http/Controller/Auth文件夹中复制文件
Create a new folder Http/Controller/Adminauth and copy the files from Http/Controller/Auth folder
打开文件Http/Controller/Adminauth/AuthController.php,做如下修改
Open the file Http/Controller/Adminauth/AuthController.php and make the following changes
新建文件夹Http/Controller/admin,复制Http/Controller/文件夹下的Controller.php文件
Create new folder Http/Controller/admin, copy Controller.php file in the folder from Http/Controller/
新建文件Http/Controller/admin/employee.php
create new file Http/Controller/admin/employee.php
移动到资源/视图创建新文件夹资源/视图/管理复制
move to resources/views create new folder resources/views/admin copy
resources/views/auth、resources/views/layouts &资源/视图/home.blade.php
并发布到 resources/views/admin
并打开 admin 文件夹中的每个文件并在每个路径前添加 admin,现在路径应该看起来像
and post into resources/views/admin
and open the each file in admin folder and add admin before each path, Now the path should look like
@extends('admin.layouts.app')
你的 Http/routes.php 看起来像
and your Http/routes.php look like
那就是在浏览器中打开您的网站并检查和管理员 yoursiteurl/admin
Thats it open your site in browser and check and for admin yoursiteurl/admin
享受....
这篇关于如何在 Laravel 5.2 中使用多重身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!