only one account per fcm_token (2)
This commit is contained in:
parent
b21b159b95
commit
a3b2a1b14f
@ -15,10 +15,15 @@ $user_key = generateRandomAuthKey();
|
||||
|
||||
$pdo = getDatabase();
|
||||
|
||||
$pdo->beginTransaction();
|
||||
|
||||
if ($ispro)
|
||||
{
|
||||
if (!verifyOrderToken($pro_token)) die(json_encode(['success' => false, 'message' => 'Purchase token could not be verified']));
|
||||
|
||||
if (!verifyOrderToken($pro_token))
|
||||
{
|
||||
$pdo->rollBack();
|
||||
die(json_encode(['success' => false, 'message' => 'Purchase token could not be verified']));
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare('UPDATE users SET is_pro=0, pro_token=NULL WHERE user_id <> :uid AND pro_token = :ptk');
|
||||
$stmt->execute(['uid' => $user_id, 'ptk' => $pro_token]);
|
||||
@ -28,6 +33,11 @@ $stmt = $pdo->prepare('INSERT INTO users (user_key, fcm_token, is_pro, pro_token
|
||||
$stmt->execute(['key' => $user_key, 'token' => $fcmtoken, 'bpro' => $ispro, 'spro' => $ispro ? $pro_token : null]);
|
||||
$user_id = $pdo->lastInsertId('user_id');
|
||||
|
||||
$stmt = $pdo->prepare('UPDATE users SET fcm_token=NULL WHERE user_id <> :uid AND fcm_token=:ft');
|
||||
$stmt->execute(['uid' => $user_id, 'ft' => $fcm_token]);
|
||||
|
||||
$pdo->commit();
|
||||
|
||||
echo json_encode(
|
||||
[
|
||||
'success' => true,
|
||||
|
Loading…
Reference in New Issue
Block a user