如何使用身份验证的中间件来管理登录/不同用户类型的重定向? [英] How to use auth middleware to manage login/redirect of different user types?

查看:139
本文介绍了如何使用身份验证的中间件来管理登录/不同用户类型的重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立两个登录路径,

I want to set up two login paths,


  • /管理/

  • /用户/

Laravel 5提供身份验证的中间件进行身份验证。中间件还提供了登录名,密码重置等默认视图,这我打算按原样使用,功能上。

Laravel 5 provides auth middleware for authentication. The middleware also provides default views for login, password reset, etc, which I'm planning use as-is, functionally.

!:需要什么样的变化routes.php文件,并在控制器来管理这两个登录?

!: What changes are needed in routes.php and in Controllers to manage these two logins?

!!:我怎样管理他们的重定向(一个管理面板,等回到主页)? (presently AUTH重定向到默认的'家'视图)

!!: How do I manage their redirects (one to admin panel, other back to homepage)? (presently auth redirects to 'home' view by default)

编辑:我知道如何prevent未经授权的访问,但是我说的是一个安装在那里我可以同时管理独立访问

I know how to prevent unauthorized access, however I'm talking about a setup where I can manage both accesses separately.

推荐答案

管理员和用户在同一laravel应用程序是一个坏主意,只是因为应用程序将共享相同的会话和​​存储信息。会有EGDE案件无数,这将导致信息通过任何逻辑墙设置了流血,你将最终花费了太多的时间修补那些出血。你真正想要做的是建立独立的laravel应用程序的每个:admin.project.com&放大器; project.com。这样,你得到两个单独的会话和存储。所有你需要做的是确保你所需要的数据库是两个database.php中配置文件的设置。你甚至可以承载独立部署在同一台服务器上的两个项目,听取不同的端口。相信我,这是最好的一段路要走。

Admin and Users in the same laravel app is a bad idea simply because the app will share the same session and storage information. There will be a myriad of egde cases that will cause information to bleed through any logic "walls" you set up and you'll end up spending way too much time patching those bleeds. What you really want to do is set up separate laravel applications for each: admin.project.com & project.com. That way you get two separate sessions and storage. All you need to do is ensure that the databases you need are setup in both database.php config files. You can even host BOTH projects on the same server with separate deployments, listening to different ports. TRUST ME this is the best way to go.

这篇关于如何使用身份验证的中间件来管理登录/不同用户类型的重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆