In this section, we complete the login logout function, set up middleware in the route, filter some illegal requests, about middleware , user authorization Please refer to the official documentation, if it is novice, it is highly recommended to first look at the document and then start the following work.
First look at the routes.php log-out route:
################# Login Logout function ############# #Route:: Get (' login ', [ ' middleware ' = ' guest ', ' as ' = ' login ', ' Usersinfo ' = ' logincontroller@loginget '); Route::p ost (' Login ', [ ' middleware ' + ' guest ', ' usersinfo ' = ' logincontroller@loginpost ']); Route::get (' logout ', [ ' middleware ' = ' auth ', ' as ' = ' logout ', ' usersinfo ' = ' logincontroller@logout ']) ;
Guest only allows visitors (without landing) access to get routing login and post routing login, if already logged in, will jump to the corresponding page, note the keyword response. There are two types of login users, students, and administrators who, when they log in, want to access these two routes, will definitely respond differently. That is, students, jump to student homepage, admin, jump to admin homepage. Now look at redirectifauthenticated.php.