fixed js logic for errors
This commit is contained in:
parent
c63274f7a9
commit
9dca27177f
@ -34,10 +34,10 @@ function send()
|
|||||||
if (xhr.readyState !== 4) return;
|
if (xhr.readyState !== 4) return;
|
||||||
|
|
||||||
console.log('Status: ' + xhr.status);
|
console.log('Status: ' + xhr.status);
|
||||||
if (xhr.status === 200)
|
if (xhr.status === 200 || xhr.status === 401 || xhr.status === 403 || xhr.status === 412)
|
||||||
{
|
{
|
||||||
let resp = JSON.parse(xhr.responseText);
|
let resp = JSON.parse(xhr.responseText);
|
||||||
if (!resp.success)
|
if (!resp.success || xhr.status !== 200)
|
||||||
{
|
{
|
||||||
if (resp.errhighlight === 101) uid.classList.add('input-invalid');
|
if (resp.errhighlight === 101) uid.classList.add('input-invalid');
|
||||||
if (resp.errhighlight === 102) key.classList.add('input-invalid');
|
if (resp.errhighlight === 102) key.classList.add('input-invalid');
|
||||||
|
@ -42,7 +42,7 @@ try
|
|||||||
$stmt->execute(['uid' => $user_id]);
|
$stmt->execute(['uid' => $user_id]);
|
||||||
|
|
||||||
$datas = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
$datas = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
if (count($datas)<=0) die(json_encode(['success' => false, 'error' => ERR::USER_NOT_FOUND, 'errhighlight' => 101, 'message' => 'User not found']));
|
if (count($datas)<=0) api_return(401, ['success' => false, 'error' => ERR::USER_NOT_FOUND, 'errhighlight' => 101, 'message' => 'User not found']);
|
||||||
$data = $datas[0];
|
$data = $datas[0];
|
||||||
|
|
||||||
if ($data === null) api_return(401, ['success' => false, 'error' => ERR::USER_NOT_FOUND, 'errhighlight' => 101, 'message' => 'User not found']);
|
if ($data === null) api_return(401, ['success' => false, 'error' => ERR::USER_NOT_FOUND, 'errhighlight' => 101, 'message' => 'User not found']);
|
||||||
|
Loading…
Reference in New Issue
Block a user