Advertisement
Guest User

Untitled

a guest
Sep 29th, 2011
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. The controller does what it is suppose to do: Control. User authentication can mainly be seen as a controlling method to either allow or deny a user access.
  2.  
  3. There is no problem if you want to create a function validateUser($username,$password) within your model.
  4.  
  5. However placing validation in the Model can strain on resources.
  6. 1.) You need to pass values values every time to authenticate
  7. 2.) authenticating every time on the model means additional and unnecessary load
  8.  
  9. If you do want to authenticate write a small wrapper... e.g. you wish to add a new product via API, but it will require adding details to another table as well. Here, you have 2 tables you need to add to, so you create a single point of entry (wrapper) and place the authentication model here.
  10.  
  11. function myAddUserWrapper($loginArray, $productArray, $categoryArray)
  12. {
  13. $auth = $this->validateUser($loginArray);
  14. if (!$auth)
  15. return 'NO!'
  16.  
  17. $this->createProduct($productArray);
  18. $this->categoryProduct($categoryArray);
  19.  
  20. }
  21.  
  22. ps: the wrapper i am refering to is just a small function that combines relevant details together as per example.
  23.  
  24. Hope it helps.
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement