views:

67

answers:

1

I have a social network-esque site with a nice User model that seems to be covering all my bases right now.

I am reworking the code from spaghetti and want to find the best-practice solution for logging in / registering a user. Here are my options (I think):

  1. Create a separate Auth class (model?) that simply searches for a record of a user and returns a new User object if found.

  2. Add "login" functionality to the User class that will allow me to log my user in as any User object that I'd like.

Please let me know the cleanest way to go about this, as I am new to good coding practices (admittedly)

+2  A: 

Just do it separately in such a manner that you can extend the class later to do stuff like FB, OAuth, OpenID login, etc.

Kemo
yeah...good point. flexible.
johnnietheblack