Yii Framework Forum: Login form as index page - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Login form as index page Rate Topic: -----

#1 User is offline   vjbill 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 18-May 10
  • Location:Poland

Posted 02 June 2010 - 02:33 PM

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
0

#2 User is offline   zitter 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 140
  • Joined: 14-July 09

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
0

#3 User is offline   vjbill 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 18-May 10
  • Location:Poland

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 the extensions 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
0

#4 User is offline   zitter 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 140
  • Joined: 14-July 09

Posted 02 June 2010 - 05:29 PM

yes, if other controllers extends Controller. Remember only to something like this in child controllers:

public functions filters()
{
    return parent::filters();
}


In this way you inherit filters'access policy from parent controller.

Ciao
Danilo
0

#5 User is offline   vjbill 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 18-May 10
  • Location:Poland

Posted 03 June 2010 - 05:53 AM

Thanks :)
I'll give that a try.

Kind regards,
Bill
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users