1
This commit is contained in:
commit
c45083c473
@ -30,7 +30,20 @@ class BaseAuthedController extends BaseController {
|
|||||||
if (!phpcommon\isValidSessionId($this->accountId,
|
if (!phpcommon\isValidSessionId($this->accountId,
|
||||||
$this->sessionId)) {
|
$this->sessionId)) {
|
||||||
phpcommon\sendError(500, 'invalid session_id');
|
phpcommon\sendError(500, 'invalid session_id');
|
||||||
die();
|
die();
|
||||||
|
}
|
||||||
|
if (!(getReqVal('c', '') == 'User' && getReqVal('c', '') == 'login')) {
|
||||||
|
$r = $this->_getRedis($this->_getAccountId());
|
||||||
|
$sessionId = $r->get(LAST_SESSION_KEY . $this->_getAccountId());
|
||||||
|
if (empty($sessionId)) {
|
||||||
|
$this->updateSession(myself()->_getAccountId(),
|
||||||
|
myself()->_getSessionId());
|
||||||
|
} else if ($sessionId != $this->_getSessionId()) {
|
||||||
|
error_log('session expiration' . json_encode(
|
||||||
|
$_REQUEST
|
||||||
|
));
|
||||||
|
phpcommon\sendError(1001, 'session expiration');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!(getReqVal('c', '') == 'User' && getReqVal('c', '') == 'login')) {
|
if (!(getReqVal('c', '') == 'User' && getReqVal('c', '') == 'login')) {
|
||||||
$r = $this->_getRedis($this->_getAccountId());
|
$r = $this->_getRedis($this->_getAccountId());
|
||||||
@ -50,8 +63,8 @@ class BaseAuthedController extends BaseController {
|
|||||||
protected function updateSession($accountId, $sessionId)
|
protected function updateSession($accountId, $sessionId)
|
||||||
{
|
{
|
||||||
$r = $this->_getRedis($this->_getAccountId());
|
$r = $this->_getRedis($this->_getAccountId());
|
||||||
$r->set(LAST_SESSION_KEY . $this->_getAccountId());
|
$r->set(LAST_SESSION_KEY . $this->_getAccountId(), $sessionId);
|
||||||
$r->pexpire(LAST_SESSION_KEY . $this->_getAccountId(), 3600 * 24);
|
$r->pexpire(LAST_SESSION_KEY . $this->_getAccountId(), 1000 * 3600 * 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _getAccountId()
|
public function _getAccountId()
|
||||||
|
@ -24,8 +24,8 @@ class UserController extends BaseAuthedController {
|
|||||||
|
|
||||||
public function login()
|
public function login()
|
||||||
{
|
{
|
||||||
$this->updateSession(myself()->_getAccountId(), myself()->_getSessionId());
|
$this->updateSession(myself()->_getAccountId(),
|
||||||
|
myself()->_getSessionId());
|
||||||
//$user_name = $_REQUEST['name'];
|
//$user_name = $_REQUEST['name'];
|
||||||
//$avatar_url = $_REQUEST['avatar_url'];
|
//$avatar_url = $_REQUEST['avatar_url'];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user