Reputation: 179
PROBLEM AT HAND:
I am creating a "micro web site" with no more than 10 pages. The login form is on the home page when a user isn't signed in. Here is a quick break down.
Public Access Pages:
Member Access Pages:
Potential Solution:
I am not sure the best solution for my controllers. I was thinking of using 2 controllers, a public controller, and a member controller. My default controller would be public. The constructor will check if a user is logged in, and if they are, redirect them to the member controller:
redirect('member')
The member page will be loaded, which has a few more links than the public page. And when a use clicks to enter contest, the member constructor makes sure they are logged in, and then shows the contest view.
Is this how it should be done to have privileged access. I will also add an admin page for the administrator to change the prizes. So there will be 3 privileges.
Thanks!
Upvotes: 0
Views: 222
Reputation: 1254
You did great to name all of your view files there. Now, other than the 2 home views, you can create a controller for each of those views and a model for the controllers that need access to a database.
In the construct for each of your privileged controllers, check the person's access level. If they don't have access for those pages, redirect them somewhere else or possibly load a view with an error message.
With the home view, it's the same except you are just deciding whether to load the non-member or member home page depending on whether they are logged in or not. I.e. you don't really need a redirect on failure.
Upvotes: 1