Hello,
I've used the search function, but with no luck...
I'm trying to do this in an elegant way.
What I want is a design similar to Gii - the user is prompted to login before being able to access the rest of the site. There will be also a 'Create account' link under the user name/password fields.
Now what my problem is: if I have a default controller (e.g. SiteController), should I use filters? Or override the beforeControllerAction method (that's what Gii does)? Or should I have another controller just to handle the login view/form? Most of the examples I saw, have an index page with a Login/Logout menu entry - not what I'm looking for.
Please let me know your opinions :-)
Thanks in advance,
Bill
Page 1 of 1
Login form as index page
#2
Posted 02 June 2010 - 02:43 PM
I think best solution for that is to use one of ready-to-use extesion in repository. Look here: http://www.yiiframew...tensions/?cat=1
After that, you can create a "parent" controller (for example MyController.php in 'components' direcotry) and then make other controllers extend MyController. In MyController, at last, you could use a filter to protect entire site access.
HTH
danilo
After that, you can create a "parent" controller (for example MyController.php in 'components' direcotry) and then make other controllers extend MyController. In MyController, at last, you could use a filter to protect entire site access.
HTH
danilo
#3
Posted 02 June 2010 - 04:10 PM
Hello,
Thanks for your reply. I will look at the extensions, but as this is a uni project, I can't rely heavily on not self-made code... :-|
Anyway, there is the class Controller, which came in theextensions components directory (when my webapp was created with yiic). All other controllers inherit from this class. Would it be a good place to put the filter there?
Kind regards,
Bill
Thanks for your reply. I will look at the extensions, but as this is a uni project, I can't rely heavily on not self-made code... :-|
Anyway, there is the class Controller, which came in the
Kind regards,
Bill
#4
Posted 02 June 2010 - 05:29 PM
yes, if other controllers extends Controller. Remember only to something like this in child controllers:
In this way you inherit filters'access policy from parent controller.
Ciao
Danilo
public functions filters()
{
return parent::filters();
}
In this way you inherit filters'access policy from parent controller.
Ciao
Danilo
Share this topic:
Page 1 of 1

Help













