Avoid using other libraries in own library |
Thanks for your answer!
(08-03-2016, 05:17 PM)cartalot Wrote: Trying to combine validating a login form - And - returning a user session - both in the same method - is messy.That's why I have one method setting the user session (In my library), and another one used to validate forms (Controller). Quote:Codeigniter form validation is awesome because of all the different things you can check. But if all you are checking for is if there is a value in the form field then you could easily do without it.I know, but I will add rules in the future. Plus, form validator has a really nice error system. So I'd like, or even need, to keep using it. Only in my controller though, and not in my library. Quote: Something to consider - instead of just checking whether a user is logged in, you can also return a $this->user object to then be available in your application.Well, the thing is that the library, used for authentication, is globally available in every controller. Quote:So then instead of something asking 'is this user logged in?' - it can try to get the user object, and if its not returned, redirect to the login page.The method isn't really about checking if the user is logged in, but about logging in the user. Checking if he already is logged in is just a "security" procedure. And with your method, the same problem as I have with my code persists: I need to check if the user is logged in before validating the form, but that would mean that I'd have to call my library's function twice. Which is ugly... |
Messages In This Thread |
Avoid using other libraries in own library - by Call-Me-Captain - 08-03-2016, 10:57 AM
RE: Avoid using other libraries in own library - by cartalot - 08-03-2016, 05:17 PM
RE: Avoid using other libraries in own library - by Call-Me-Captain - 08-04-2016, 04:19 AM
RE: Avoid using other libraries in own library - by PaulD - 08-04-2016, 05:20 AM
RE: Avoid using other libraries in own library - by Call-Me-Captain - 08-04-2016, 05:38 AM
RE: Avoid using other libraries in own library - by ivantcholakov - 08-04-2016, 05:53 AM
RE: Avoid using other libraries in own library - by PaulD - 08-04-2016, 06:06 AM
RE: Avoid using other libraries in own library - by mwhitney - 08-04-2016, 06:38 AM
RE: Avoid using other libraries in own library - by Call-Me-Captain - 08-06-2016, 02:03 PM
|