Laravel5 student score management system-03-login and logout Function-permission-Middleware
In this section, we complete the login and logout Function, set middleware in the routing, and filter some illegal requests.Middleware,User authorizationPlease refer to the official documentation. if you are a newbie, we strongly recommend that you first read the documentation and start the following work.
First look at the route for logging out of routes. php:
################# Login and logout ############## Route :: get ('login', ['middleware '=> 'guest', 'as' => 'login', 'usersinfo '=> 'logincontroller @ LoginGet']); Route:: post ('login', ['middleware '=> 'guest', 'usersinfo '=> 'logincontroller @ loginpost']); Route: get ('logo ', ['middleware '=> 'auth', 'as' => 'logo', 'usersinfo' => 'logincontroller @ logo']);
Guest only allows visitors (without logon) to access the get route login and post route login. if they have logged on, they will jump to the corresponding page and pay attention to the keyword response. There are two types of login users: Students and administrators. when they log on, they will definitely make different responses to access these two routes. That is, students go to the student homepage, administrators, and administrators homepage. now let's take a look at RedirectIfAuthenticated. php