PMC-119
This commit is contained in:
@@ -326,6 +326,8 @@ try {
|
||||
}
|
||||
|
||||
if ($RBAC->singleSignOn) {
|
||||
// Update the User's last login date
|
||||
updateUserLastLogin($aLog);
|
||||
G::header('Location: ' . $sLocation);
|
||||
die();
|
||||
}
|
||||
@@ -336,6 +338,8 @@ try {
|
||||
if ($changePassword === true) {
|
||||
$user = new User();
|
||||
$currentUser = $user->changePassword($_SESSION['USER_LOGGED'], $_POST['form']['USR_PASSWORD']);
|
||||
// Update the User's last login date
|
||||
updateUserLastLogin($aLog);
|
||||
G::header('Location: ' . $currentUser["__REDIRECT_PATH__"]);
|
||||
return;
|
||||
}
|
||||
@@ -394,6 +398,9 @@ try {
|
||||
setcookie("PM-TabPrimary", 101010010, time() + (24 * 60 * 60), '/');
|
||||
}
|
||||
|
||||
// Update the User's last login date
|
||||
updateUserLastLogin($aLog);
|
||||
|
||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
||||
if ($oPluginRegistry->existsTrigger ( PM_AFTER_LOGIN )) {
|
||||
$oPluginRegistry->executeTriggers ( PM_AFTER_LOGIN , $_SESSION['USER_LOGGED'] );
|
||||
|
||||
@@ -116,12 +116,6 @@ if (isset($_SESSION['USER_LOGGED'])) {
|
||||
$aLog['USR_UID'] = $aRow['USR_UID'];
|
||||
|
||||
$weblog->update($aLog);
|
||||
|
||||
$aLog = array();
|
||||
$aLog['USR_UID'] = $aRow['USR_UID'];
|
||||
$aLog['USR_LAST_LOGIN'] = $endDate;
|
||||
$user = new Users();
|
||||
$aUser = $user->update($aLog);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Exception;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
@@ -39,4 +40,26 @@ class User extends Model
|
||||
{
|
||||
return User::find($usrUid)->groups()->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope for the specified user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param array $filters
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
* @throws Exception
|
||||
*/
|
||||
public function scopeUserFilters($query, array $filters)
|
||||
{
|
||||
if (!empty($filters['USR_ID'])) {
|
||||
$query->where('USR_ID', $filters['USR_ID']);
|
||||
} elseif (!empty($filters['USR_UID'])) {
|
||||
$query->where('USR_UID', $filters['USR_UID']);
|
||||
} else {
|
||||
throw new Exception("There are no filter for loading a user model");
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Illuminate\Support\Str;
|
||||
use ProcessMaker\Model\User;
|
||||
|
||||
/**
|
||||
* We will send a case note in the actions by email
|
||||
@@ -493,3 +494,29 @@ if (!function_exists('set_magic_quotes_runtime')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the USER table with the last login date
|
||||
*
|
||||
* @param array $userLog
|
||||
* @return int
|
||||
* @throws Exception
|
||||
*
|
||||
* @see workflow/engine/methods/login/authentication.php
|
||||
*/
|
||||
function updateUserLastLogin($userLog, $keyLastLogin = 'LOG_INIT_DATE')
|
||||
{
|
||||
try {
|
||||
$filters = [];
|
||||
$filters['USR_UID'] = $userLog['USR_UID'];
|
||||
|
||||
$user = User::query();
|
||||
$user->userFilters($filters);
|
||||
$res = $user->update(['USR_LAST_LOGIN' => $userLog[$keyLastLogin]]);
|
||||
|
||||
return $res;
|
||||
} catch (Exception $e) {
|
||||
throw new Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user