Implemented session key auth and temporarily restored password auth.
This commit is contained in:
parent
9f14269fb6
commit
0bdd279874
1 changed files with 11 additions and 7 deletions
|
@ -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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue