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):
Create a separate Auth class (model?) that simply searches for a record of a user and returns a new User object if found.
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)
Just do it separately in such a manner that you can extend the class later to do stuff like FB, OAuth, OpenID login, etc.
精彩评论