Skip to content

Commit

Permalink
Merge pull request #127 from Dreamer0x01/dev_upd
Browse files Browse the repository at this point in the history
Корректируем автологин
  • Loading branch information
Pathologic authored Aug 2, 2022
2 parents c2189d5 + 26ab77f commit b895ee9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions assets/snippets/FormLister/plugin.userHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@
$userObj->setAutoLoginCookie($cookieName, $cookieLifetime);
}
}
//Updating session_id in cookie, if user is login and just saved
if ($e->name == 'OnWebSaveUser' && isset($userObj)) {
if( (int)$modx->getLoginUserID('web') == (int)$id && isset($_COOKIE[$cookieName]) ) { //checking, if current logined user was saved
$cookieParts = explode("|", $_COOKIE[$cookieName], 4);
if(isset($cookieParts[2]) && ($userObj->get('sessionid') != $cookieParts[2])) { //checking, if session ids in cookie and in user object became not equals
$userObj->setAutoLoginCookie($cookieName, $cookieLifetime);
}
}
}

if ($e->name == 'OnWebPageInit' || $e->name == 'OnPageNotFound') {
$model = isset($params['model']) && class_exists($params['model']) ? $params['model'] : '\\modUsers';
$user = new $model($modx);
Expand Down Expand Up @@ -64,3 +74,4 @@
$user->AutoLogin($cookieLifetime, $cookieName, true);
}
}

2 changes: 1 addition & 1 deletion install/assets/plugins/userHelper.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @category plugin
* @version 1.19.2
* @internal @properties &model=Model;text;\\modUsers &logoutKey=Request key;text;logout &cookieName=Cookie Name;text;WebLoginPE &cookieLifetime=Cookie Lifetime, seconds;text;157680000 &maxFails=Max failed logins;text;3 &blockTime=Block for, seconds;text;3600 &trackWebUserActivity=Track web user activity;list;No,Yes;No
* @internal @events OnWebAuthentication,OnWebPageInit,OnPageNotFound,OnWebLogin
* @internal @events OnWebAuthentication,OnWebPageInit,OnPageNotFound,OnWebLogin,OnWebSaveUser
* @internal @modx_category Content
* @internal @disabled 1
**/
Expand Down

0 comments on commit b895ee9

Please sign in to comment.