Laravel5学生成绩管理系统-03-登陆登出功能-权限-中间件

WBOY
Release: 2016-06-20 12:30:43
Original
945 people have browsed it



 这一节,我们完成登录登出的功能, 在路由中设置中间件, 过滤一些非法请求,关于中间件用户授权请参考官方文档,如果是新手,强烈建议先看下文档然后再开始下面的工作。

先看routes.php的登陆登出的路由:

     ################# 登陆登出功能##############Route::get('login', [    'middleware' => 'guest', 'as'=>'login', 'UsersInfo' => 'loginController@LoginGet']);Route::post('login', [    'middleware' => 'guest', 'UsersInfo' => 'loginController@LoginPost']);Route::get('logout', [    'middleware' => 'auth', 'as'=>'logout', 'UsersInfo' => 'loginController@Logout']);
Copy after login


guest 只允许游客(没登陆的情况下)访问get路由login和post路由login,要是已经登录,就会跳转到相应页面,注意关键词响应。我们登录用户有两种,学生,和管理员,当他们在登录的情况下要想访问这两个路由,肯定会做出不同的响应。即,学生,跳转到学生主页,管理员,跳转到管理员主页.现在来看看RedirectIfAuthenticated.php


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template