Added check acct correct and exists on database (still TODO)

master
Bofh 1 year ago
parent 498627051c
commit 77e398f253

@ -32,6 +32,20 @@ $auth = json_decode(file_get_contents('/src/mock-auth.mock'));
$output = mastodon_get($payload->instance,
'/api/v1/accounts/verify_credentials', $auth->access_token);
if (!preg_match('/^[a-zA-Z0-9_]+$/', $output->acct))
hres(500, 'Server returned incorrect user data, please contact the administrators');
# check user exists by acct
$acct = '@'.$output->acct.'@'.preg_replace('/^https:\/\//', '', $payload->instance);
$sm = $db->prepare('SELECT id FROM users WHERE acct = ? LIMIT 1');
$sm->execute([$acct]);
if ($sm->fetch() === false) {
echo 'User not exists. Create it';
} else {
echo 'User exists. Update data';
}
die;
var_dump($output);
echo '<br><br>';
var_dump($payload);

Loading…
Cancel
Save