feat!: allow registration of multiple users (#340)
feat: administration area feat: add reset password functionality
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
session_start();
|
||||
require_once '../../includes/connect_endpoint.php';
|
||||
|
||||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
|
||||
die(json_encode([
|
||||
@@ -28,8 +27,10 @@ require_once '../../includes/connect_endpoint.php';
|
||||
$user_key = $data["user_key"];
|
||||
$token = $data["token"];
|
||||
|
||||
$query = "SELECT COUNT(*) FROM pushover_notifications";
|
||||
$result = $db->querySingle($query);
|
||||
$query = "SELECT COUNT(*) FROM pushover_notifications WHERE user_id = :userId";
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindParam(":userId", $userId, SQLITE3_INTEGER);
|
||||
$result = $stmt->execute();
|
||||
|
||||
if ($result === false) {
|
||||
$response = [
|
||||
@@ -38,18 +39,21 @@ require_once '../../includes/connect_endpoint.php';
|
||||
];
|
||||
echo json_encode($response);
|
||||
} else {
|
||||
if ($result == 0) {
|
||||
$query = "INSERT INTO pushover_notifications (enabled, user_key, token)
|
||||
VALUES (:enabled, :user_key, :token)";
|
||||
$row = $result->fetchArray();
|
||||
$count = $row[0];
|
||||
if ($count == 0) {
|
||||
$query = "INSERT INTO pushover_notifications (enabled, user_key, token, user_id)
|
||||
VALUES (:enabled, :user_key, :token, :userId)";
|
||||
} else {
|
||||
$query = "UPDATE pushover_notifications
|
||||
SET enabled = :enabled, user_key = :user_key, token = :token";
|
||||
SET enabled = :enabled, user_key = :user_key, token = :token, user_id = :userId";
|
||||
}
|
||||
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->bindValue(':enabled', $enabled, SQLITE3_INTEGER);
|
||||
$stmt->bindValue(':user_key', $user_key, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':token', $token, SQLITE3_TEXT);
|
||||
$stmt->bindValue(':userId', $userId, SQLITE3_INTEGER);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
$response = [
|
||||
|
||||
Reference in New Issue
Block a user