Skip to content

Commit

Permalink
fix unable to login properly after implementing user_session
Browse files Browse the repository at this point in the history
  • Loading branch information
antonraharja committed Feb 27, 2014
1 parent eba46eb commit 20569c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion web/lib/fn_auth.php
Expand Up @@ -86,7 +86,7 @@ function auth_isvalid() {
if ($_SESSION['sid'] && $_SESSION['uid'] && $_SESSION['valid']) {
$s = user_session_get($_SESSION['uid']);
$items = $s[$_SESSION['sid']];
if ($items['uid'] && $items['ip'] && $items['last_update']) {
if ($items['ip'] && $items['last_update']) {
return TRUE;
}
}
Expand Down
10 changes: 4 additions & 6 deletions web/lib/fn_user.php
Expand Up @@ -273,11 +273,9 @@ function user_session_set($uid='') {
if (! $core_config['daemon_process']) {
$uid = ( $uid ? $uid : $core_config['user']['uid'] );
$c_items = array(
'sid' => $_SESSION['sid'],
'ip' => $_SERVER['REMOTE_ADDR'],
'last_update' => core_get_datetime(),
'http_user_agent' => $_SERVER['HTTP_USER_AGENT'],
'uid' => $uid
'http_user_agent' => $_SERVER['HTTP_USER_AGENT']
);
$items[$_SESSION['sid']] = json_encode($c_items);
registry_update($uid, 'auth', 'login_session', $items);
Expand All @@ -296,9 +294,9 @@ function user_session_get($uid='', $sid='') {
$uid = ( $uid ? $uid : $core_config['user']['uid'] );
$s = registry_search($uid, 'auth', 'login_session');
$sessions = $s['auth']['login_session'];
foreach ($sessions as $session) {
$tmp_ret = core_object_to_array(json_decode($session));
$c_ret[$tmp_ret['sid']] = $tmp_ret;
foreach ($sessions as $key => $val) {
$tmp_ret = core_object_to_array(json_decode($val));
$c_ret[$key] = $tmp_ret;
}
if ($sid) {
$ret[$sid] = $c_ret[$sid];
Expand Down

0 comments on commit 20569c2

Please sign in to comment.