Implemented session key auth and temporarily restored password auth.

This commit is contained in:
flash 2019-12-14 02:08:45 +01:00
parent 9f14269fb6
commit 0bdd279874

View file

@ -200,15 +200,19 @@ final class SockChatHandler extends Handler {
if(!hash_equals($realHash, $userHash)) if(!hash_equals($realHash, $userHash))
return ['success' => false, 'reason' => 'hash']; return ['success' => false, 'reason' => 'hash'];
$authMethod = substr($authInfo->token, 0, 5); $authMethod = mb_substr($authInfo->token, 0, 5);
if($authMethod === 'PASS:') if($authMethod === 'PASS:') { // DEPRECATE THIS
return ['success' => false, 'reason' => 'unsupported']; if(time() > 1577750400)
elseif($authMethod === 'SESS:') { return ['success' => false, 'reason' => 'unsupported'];
$sessionKey = substr($authInfo->token, 5);
// use session token to log in if(user_password_verify_db($authInfo->user_id, mb_substr($authInfo->token, 5)))
return ['success' => false, 'reason' => 'unimplemented']; $userId = $authInfo->user_id;
} elseif($authMethod === 'SESS:') { // IMPROVE THIS
user_session_start($authInfo->user_id, mb_substr($authInfo->token, 5));
if(user_session_active())
$userId = user_session_current('user_id');
} else { } else {
try { try {
$token = ChatToken::get($authInfo->user_id, $authInfo->token); $token = ChatToken::get($authInfo->user_id, $authInfo->token);