Connect Flutter phone auth and Android platform
This commit is contained in:
@@ -37,6 +37,7 @@ try {
|
||||
$db = Database::getInstance();
|
||||
$connection = $db->getConnection();
|
||||
$connection->begin_transaction();
|
||||
$transactionOpen = true;
|
||||
|
||||
$rateBuckets = [
|
||||
['phone', hash_hmac('sha256', 'phone:' . $phone, $hashKey), 5, 3600],
|
||||
@@ -57,6 +58,7 @@ try {
|
||||
$check->close();
|
||||
if ($count > $limit) {
|
||||
$connection->rollback();
|
||||
$transactionOpen = false;
|
||||
api_json(['error' => 'rate_limited'], 429);
|
||||
}
|
||||
}
|
||||
@@ -70,11 +72,12 @@ try {
|
||||
$insert->execute();
|
||||
$insert->close();
|
||||
$connection->commit();
|
||||
$transactionOpen = false;
|
||||
|
||||
(new ConfiguredHttpOtpProvider())->send($phone, $code);
|
||||
api_json(['challenge_id' => $challengeUuid, 'expires_in_seconds' => 300]);
|
||||
} catch (Throwable $exception) {
|
||||
if (isset($connection) && $connection instanceof mysqli && $connection->errno === 0) {
|
||||
if (!empty($transactionOpen) && isset($connection) && $connection instanceof mysqli) {
|
||||
try { $connection->rollback(); } catch (Throwable $ignored) {}
|
||||
}
|
||||
error_log('OTP request failed: ' . $exception->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user