MVC - Controller default
I mainly use Kohana and Yii, but my question is addressed to the mvc pattern in general.
The Route class, in general, call the appropriate controller as a unique resource through the url. If it is missing, it invokes the default controller.
The p开发者_StackOverflow中文版oint is this: my default page (site.com /) is to login. Once logged on does not make sense to show the login page, and returning to site.com I would like it to invoke another controller.
The possible solutions I found are: to redirect to another page, if logged. Or use HMVC. But I asked myself if there are appropriate strategies.
Have you ever been faced with a situation like this? How did you solve?
Default controller can check, if user is logged or not, and if not - call kind of LoginController
, without redirecting.
And I think it's not best Usability design, when user should login, before he could see the site.
You would probably be better off having an "admin dashboard" type controller as your default one, and do a check to see if the user is logged in or not.
If they aren't logged in, redirect to the login
controller, and if they are logged in, proceed as normal.
That would make better sense to me; at least.
精彩评论