21.2. Designing User Interaction
Now that the core has been designed, the next section can be architected. The user interaction section will be a set of modules to provide an interface to the user. The interactions that are needed are:
Authentication/authorization
Creating, editing, deleting users
Providing admin access to all users
21.2.1. Authentication and Authorization
When users access the first page of the site, there are two possible outcomes (Figure 21-3). If they are authenticated, they will see a listing of their contacts. If they are not authenticated, they will be redirected to a login page.
Figure 21-3. Figure 21-3
The IndexModule object will be an instance of the Module that I detailed in the core section. It has one public method, called default(), which is the action that the Controller object would execute during a call to render(). This method needs to make a decision whether to show a collection of contacts or to do the redirect.
Logically, I'm going to assume that the next step is to provide the login view for the user. (I'll discuss contactscollection later, but suffice it to say it's used if the current user is already authenticated.)
Login functionality will be provided by a module (Figure 21-4).
Figure 21-4. Figure 21-4
LoginModule has two public methods. ...
Get Professional PHP Design Patterns now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.