Skip to content

Commit

Permalink
login and logout of the user
Browse files Browse the repository at this point in the history
  • Loading branch information
ainaraRT committed Oct 15, 2024
1 parent b0ad6b0 commit bfd748b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
25 changes: 25 additions & 0 deletions modules/Users/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,31 @@
} else {
$url = $GLOBALS['app']->getLoginRedirect();
}

// STIC-Custom 20241014 ART - Tracker Module
// https://github.com/SinergiaTIC/SinergiaCRM/pull/211
// Track the login of the current user
if($action === 'Authenticate'){
$trackerManager = TrackerManager::getInstance();
$monitor = $trackerManager->getMonitor('tracker');

if ($monitor) {

$user = $GLOBALS['current_user'];

$monitor->setValue('date_modified', $GLOBALS['timedate']->nowDb());
$monitor->setValue('user_id', $user->id);
$monitor->setValue('assigned_user_link', $user->user_name);
$monitor->setValue('module_name', 'Users');
$monitor->setValue('action', 'login_ok');
$monitor->setValue('item_id', $user->id);
$monitor->setValue('item_summary', $user->full_name .' - Login');
$monitor->setValue('visible', true);

$trackerManager->saveMonitor($monitor, true, true);
}
}
// END STIC Custom
} else {
// Login has failed
if (isset($_POST['login_language']) && !empty($_POST['login_language'])) {
Expand Down
22 changes: 22 additions & 0 deletions modules/Users/Logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@
}

//Update the tracker_sessions table
// STIC-Custom 20241014 ART - Tracker Module
// https://github.com/SinergiaTIC/SinergiaCRM/pull/211
// Track the logout of the current user
if($action === 'Logout') {
$trackerManager = TrackerManager::getInstance();
$monitor = $trackerManager->getMonitor('tracker');

if ($monitor) {

$monitor->setValue('date_modified', $GLOBALS['timedate']->nowDb());
$monitor->setValue('user_id', $current_user->id);
$monitor->setValue('assigned_user_link', $current_user->user_name);
$monitor->setValue('module_name', 'Users');
$monitor->setValue('action', 'logout');
$monitor->setValue('item_id', $current_user->id);
$monitor->setValue('item_summary', $current_user->full_name .' - Logout');
$monitor->setValue('visible', true);

$trackerManager->saveMonitor($monitor, true, true);
}
}
// END STIC Custom
// clear out the authenticating flag
session_destroy();

Expand Down

0 comments on commit bfd748b

Please sign in to comment.