Yii Framework Forum: Logically Organize Registration - Yii Framework Forum

Jump to content

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

Logically Organize Registration Rate Topic: -----

#1 User is offline   tdk2fe 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 30-August 12

Posted 11 November 2012 - 01:37 PM

So I'm relatively new to Yii, but enjoy it thus far. I have read several articles/posts on how to implement registration, but none of them seem to answer my question - what's the best way to do it?

For example, I have two tables - m_password and m_person:

m_person:
personID
firstName
lastName
email

m_password:
id
person_id
hashedPassword
salt


I also have a model for Password and Person. My planned implementation was to create a form (class RegisterForm extends CFormModel) as well as an actionRegister method in the SiteController.

Within the SiteController, I was going to pass both models to the view:
public function actionRegister() {
$person = new Person;
$password = new Password;
...
$this->render('register', array('person'=>$person, 'password'=>$password));
}


Here are some question I had about this approach:

1.) Since the Person model is related to the Password via a HAS_ONE relationship, do I even need to create a PasswordController? Is it bad practice to access the password hash exclusively through the PersonController?

2.) Is the SiteController the best place to put generic forms such as Registration and Login?

3.) Is there anything flawed about my intended implementation?

Thanks in advance!
0

#2 User is offline   luc 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 211
  • Joined: 22-June 10
  • Location:france

Posted 11 November 2012 - 04:18 PM

Hi,
IMHO:

1) You do not need a PasswordController. All the hard stuff should be done in the model.

2) You can use site controller if you want ... But if you plan to have more functionnalities (profile editing for your user, a user search facility ...) a specific controller can be more coherent. Or even better, a reusuable module ...

3) well not really ... Do you "have to" separate "person" and "password" ?
Hey Ho !
Let's go !
0

#3 User is offline   tdk2fe 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 30-August 12

Posted 11 November 2012 - 05:17 PM

View Postluc, on 11 November 2012 - 04:18 PM, said:



3) well not really ... Do you "have to" separate "person" and "password" ?


Thanks for the reply. The reason I have a seperate table for passwords is that the m_person table will have records for people who are not necessarily users of the site.

I figured for all of the person profiles, editing, searching I would simply use the PersonController and Person model.
0

#4 User is offline   luc 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 211
  • Joined: 22-June 10
  • Location:france

Posted 11 November 2012 - 05:34 PM

Quote

The reason I have a seperate table for passwords is that the m_person table will have records for people who are not necessarily users of the site.


Understand now.

Did you know that Yii have some built in classes that might help you especially CWebUser ?
Hey Ho !
Let's go !
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