-
-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: allow registration of multiple users (#340)
feat: administration area feat: add reset password functionality
- Loading branch information
Showing
90 changed files
with
3,093 additions
and
829 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php | ||
|
||
require_once '../../includes/connect_endpoint.php'; | ||
|
||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) { | ||
die(json_encode([ | ||
"success" => false, | ||
"message" => translate('session_expired', $i18n) | ||
])); | ||
} | ||
|
||
// Check that user is an admin | ||
if ($userId !== 1) { | ||
die(json_encode([ | ||
"success" => false, | ||
"message" => translate('error', $i18n) | ||
])); | ||
} | ||
|
||
if ($_SERVER["REQUEST_METHOD"] === "POST") { | ||
|
||
$postData = file_get_contents("php://input"); | ||
$data = json_decode($postData, true); | ||
|
||
$userId = $data['userId']; | ||
|
||
if ($userId == 1) { | ||
die(json_encode([ | ||
"success" => false, | ||
"message" => translate('error', $i18n) | ||
])); | ||
} else { | ||
// Delete user | ||
$stmt = $db->prepare('DELETE FROM user WHERE id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete subscriptions | ||
$stmt = $db->prepare('DELETE FROM subscriptions WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete settings | ||
$stmt = $db->prepare('DELETE FROM settings WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete fixer | ||
$stmt = $db->prepare('DELETE FROM fixer WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete custom colors | ||
$stmt = $db->prepare('DELETE FROM custom_colors WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete currencies | ||
$stmt = $db->prepare('DELETE FROM currencies WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete categories | ||
$stmt = $db->prepare('DELETE FROM categories WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete household | ||
$stmt = $db->prepare('DELETE FROM household WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete payment methods | ||
$stmt = $db->prepare('DELETE FROM payment_methods WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete email notifications | ||
$stmt = $db->prepare('DELETE FROM email_notifications WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete telegram notifications | ||
$stmt = $db->prepare('DELETE FROM telegram_notifications WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete webhook notifications | ||
$stmt = $db->prepare('DELETE FROM webhook_notifications WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete gotify notifications | ||
$stmt = $db->prepare('DELETE FROM gotify_notifications WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete pushover notifications | ||
$stmt = $db->prepare('DELETE FROM pushover_notifications WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Dele notification settings | ||
$stmt = $db->prepare('DELETE FROM notification_settings WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete last exchange update | ||
$stmt = $db->prepare('DELETE FROM last_exchange_update WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
// Delete email verification | ||
$stmt = $db->prepare('DELETE FROM email_verification WHERE user_id = :id'); | ||
$stmt->bindValue(':id', $userId, SQLITE3_INTEGER); | ||
$result = $stmt->execute(); | ||
|
||
die(json_encode([ | ||
"success" => true, | ||
"message" => translate('success', $i18n) | ||
])); | ||
|
||
} | ||
|
||
} else { | ||
die(json_encode([ | ||
"success" => false, | ||
"message" => translate('error', $i18n) | ||
])); | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
require_once '../../includes/connect_endpoint.php'; | ||
|
||
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) { | ||
die(json_encode([ | ||
"success" => false, | ||
"message" => translate('session_expired', $i18n) | ||
])); | ||
} | ||
|
||
// Check that user is an admin | ||
if ($userId !== 1) { | ||
die(json_encode([ | ||
"success" => false, | ||
"message" => translate('error', $i18n) | ||
])); | ||
} | ||
|
||
if ($_SERVER["REQUEST_METHOD"] === "POST") { | ||
|
||
$postData = file_get_contents("php://input"); | ||
$data = json_decode($postData, true); | ||
|
||
$openRegistrations = $data['open_registrations']; | ||
$maxUsers = $data['max_users']; | ||
$requireEmailVerification = $data['require_email_validation']; | ||
$serverUrl = $data['server_url']; | ||
|
||
if ($requireEmailVerification == 1 && $serverUrl == "") { | ||
echo json_encode([ | ||
"success" => false, | ||
"message" => translate('fill_all_fields', $i18n) | ||
]); | ||
die(); | ||
} | ||
|
||
$sql = "UPDATE admin SET registrations_open = :openRegistrations, max_users = :maxUsers, require_email_verification = :requireEmailVerification, server_url = :serverUrl"; | ||
$stmt = $db->prepare($sql); | ||
$stmt->bindParam(':openRegistrations', $openRegistrations, SQLITE3_INTEGER); | ||
$stmt->bindParam(':maxUsers', $maxUsers, SQLITE3_INTEGER); | ||
$stmt->bindParam(':requireEmailVerification', $requireEmailVerification, SQLITE3_INTEGER); | ||
$stmt->bindParam(':serverUrl', $serverUrl, SQLITE3_TEXT); | ||
$result = $stmt->execute(); | ||
|
||
if ($result) { | ||
echo json_encode([ | ||
"success" => true, | ||
"message" => translate('success', $i18n) | ||
]); | ||
} else { | ||
echo json_encode([ | ||
"success" => false, | ||
"message" => translate('error', $i18n) | ||
]); | ||
} | ||
} | ||
|
||
?> |
Oops, something went wrong.