Fixed session authentication.
This commit is contained in:
parent
7ef2a4d3a5
commit
5c3747ecb6
1 changed files with 13 additions and 4 deletions
|
@ -2,6 +2,7 @@
|
||||||
namespace Misuzu\Http\Handlers;
|
namespace Misuzu\Http\Handlers;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Misuzu\Base64;
|
||||||
use Misuzu\Config;
|
use Misuzu\Config;
|
||||||
use Misuzu\DB;
|
use Misuzu\DB;
|
||||||
use Misuzu\Emoticon;
|
use Misuzu\Emoticon;
|
||||||
|
@ -202,15 +203,23 @@ final class SockChatHandler extends Handler {
|
||||||
|
|
||||||
$authMethod = mb_substr($authInfo->token, 0, 5);
|
$authMethod = mb_substr($authInfo->token, 0, 5);
|
||||||
|
|
||||||
if($authMethod === 'PASS:') { // DEPRECATE THIS
|
if($authMethod === 'PASS:') {
|
||||||
if(time() > 1577750400)
|
if(time() > 1577750400)
|
||||||
return ['success' => false, 'reason' => 'unsupported'];
|
return ['success' => false, 'reason' => 'unsupported'];
|
||||||
|
|
||||||
if(user_password_verify_db($authInfo->user_id, mb_substr($authInfo->token, 5)))
|
if(user_password_verify_db($authInfo->user_id, mb_substr($authInfo->token, 5)))
|
||||||
$userId = $authInfo->user_id;
|
$userId = $authInfo->user_id;
|
||||||
} elseif($authMethod === 'SESS:') { // IMPROVE THIS
|
} elseif($authMethod === 'SESS:') {
|
||||||
$tokenData = user_session_cookie_unpack(mb_substr($authInfo->token, 5), true);
|
$sessionToken = mb_substr($authInfo->token, 5);
|
||||||
user_session_start($authInfo->user_id, $tokenData['token']);
|
$tokenData = user_session_cookie_unpack(
|
||||||
|
Base64::decode($sessionToken, true),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
if(isset($tokenData['session_token']))
|
||||||
|
$sessionToken = $tokenData['session_token'];
|
||||||
|
|
||||||
|
user_session_start($authInfo->user_id, $sessionToken);
|
||||||
|
|
||||||
if(user_session_active())
|
if(user_session_active())
|
||||||
$userId = user_session_current('user_id');
|
$userId = user_session_current('user_id');
|
||||||
|
|
Loading…
Add table
Reference in a new issue