Episode completed

Next epsiode starting in 3 seconds

Published at


To have users log in on your page, we first need to establish a table for said users. There, we need to store information, like the E-Mail, the hash of the password, when the user was locked and how many failed login attempts the user had. That information is the minimum required by the IHP authentication module. That module saves the passwords as a salted hash. A user is locked for an hour after 10 failed login attempts. After creating the User Table, you need to Update your Database. To use the authentication module, you need to add the LoginSupport helper in the Application Helper Controller. You also need to import the Generated Types to access the User type we just created. Also, create a type instance like this. Now, switch to the View Helper and also import the LoginSupport Helper there. In your FrontController import the LoginSupport Middleware and the Sessions Controller we are going to create later. also add a route for the Sessions Controller. Next, init user authentication in your the Controller Context of the Application. Now we can create the Sessions Controller. Conveniently, the IHP Guide contains a sample Controller and View we can use. First we need to import the LoginSupport Types and add the new Session Url to our Types. We also need to add the Types for the Controller. In the Routes we also need to add the Controller. Now we can create the Sessions Controller File and add the sample Code from the Guide. The same goes for the new session view. The sessions controller is now implemented. To use it, we just need to refer to the NewSessionAction in a login button. That takes you to the Login View we just created.