‫Okay, so we have a complete Crud app now with a nice base slash infrastructure framework, whatever
‫you want to call it.
‫Now we're going to start adding authentication and authorization.
‫Now this is a vanilla PHP course.
‫So we'll be doing everything manually with sessions.
‫But just know that there are many packages and libraries and stuff that you can use to help with this.
‫So we already have a user's table.
‫We need to create a users controller as well as a view for the login and register pages.
‫Then we can add the logic to register a user and log them in create the session.
‫We'll also add a log out method obviously, and we'll do this with the help of a session class that
‫we'll create.
‫Now we're going to be adding middleware to our routes as well.
‫Middleware is code that runs before a controller method, and we'll be using it to basically just check
‫to see if a user is logged in or not, and then directing them to the correct place.
‫Then we can protect certain routes we don't want just anybody to be able to create a listing or edit
‫a listing and things like that.
‫Then we'll be able to make it so only listing owners can edit and delete those listings.
‫And we'll also add flash messages to the session class so that we don't have to use the session superglobal
‫directly in the controllers.
‫So that's kind of the gist of what we're going to do in this section.
‫So let's get to work.