开发者

MVC authentication - it's own model?

开发者 https://www.devze.com 2022-12-15 08:15 出处:网络
I have a social network-esque site with a nice User model that seems to be covering all my bases right now.

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.

  3. 开发者_如何转开发

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消