__construct my bad code with Ion Auth - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7) +--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13) +--- Thread: __construct my bad code with Ion Auth (/showthread.php?tid=65749) |
__construct my bad code with Ion Auth - Sarog - 07-19-2016 Good day I use authorization with Ion Auth. Registraition work and all good, but my code is so bad. I use it each controller in order to understand whether the user is registered. PHP Code: private $logged_in; RE: __construct my bad code with Ion Auth - InsiteFX - 07-19-2016 I believe ION Auth comes with a MY_Controller you can add other classes to the MY_Controller and add your code to it a new Controller class. Just extend the MY_Controller to your new Controller. RE: __construct my bad code with Ion Auth - Sarog - 07-19-2016 I'm sorry. for understanding how it works, I took only some functions in Ion Auth/ I don't see MY_Controller RE: __construct my bad code with Ion Auth - InsiteFX - 07-19-2016 Ion Auth uses the Auth Controller what I am saying is to create a MY_Controller you can find that in the Users Guide, then create your own Controller and a dd the methods you need to it. You could even place the auth controller in the MY_Controller class. RE: __construct my bad code with Ion Auth - jaynarayan - 07-19-2016 (07-19-2016, 04:20 PM)Sarog Wrote: I'm sorry. for understanding how it works, I took only some functions in Ion Auth/ use MY_Controller as the base class and extends all your controller from it.the code which is required in all controller goes into MY_controller and you don't have to copy paste in each controller. some common usages: 1)authentication code. 2)loading common libraries , helper or any other resources 3)enable disable profiler or caching 4) simple template system etc google or search on git hub . you will find some good examples. RE: __construct my bad code with Ion Auth - Avenirer - 07-19-2016 (07-19-2016, 03:56 PM)Sarog Wrote: Good day First of all... that is a really bad code... Why are you calling a CI instance inside the controller? Isn't it already called? Anyway... Besides pointing you to the official documentation which is more than great, I can also refer you to a series about Ion_auth (on my own blog...): http://avenir.ro/authentication-system-with-ion-auth-and-ci3/ In there you also have a few more tutorials about working with CodeIgniter. |