CommunityAuth Login/Logout Hooks/Functions - 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: CommunityAuth Login/Logout Hooks/Functions (/showthread.php?tid=70153) |
CommunityAuth Login/Logout Hooks/Functions - sjcarr - 03-01-2018 I'm looking for the best way to implement the following... I have CommunityAuth up and running, works great. But I want to log/audit login/logout actions. I have a separate auditlog() function already written for this, but where is the best place call it from? Inside the Auth_Model login_update() function for login? Inside the Auth_Model logout() function for logout? Thanks RE: CommunityAuth Login/Logout Hooks/Functions - skunkbad - 03-02-2018 What exactly are you logging? RE: CommunityAuth Login/Logout Hooks/Functions - sjcarr - 03-02-2018 On login: user_id, timestamp, IP address On logout: user_id, timestamp RE: CommunityAuth Login/Logout Hooks/Functions - skunkbad - 03-02-2018 Community Auth has a method in Auth_Controller called post_auth_hook, and so MY_Controller is a great place to extend that method and do what you want to do when they log in. Unfortunately, there is not yet a hook called at logout. This really wouldn't be hard to implement though. In the logout method of your controller that handles logout, simply check to see if the person is logged in before logging them out. This check provides you with an opportunity to log the details. |