From d6ca2e6e0086812de114b173122bee5e95b03db1 Mon Sep 17 00:00:00 2001 From: Anonymous Contributor Date: Sun, 27 Aug 2023 12:17:33 +0200 Subject: [PATCH] Move identity deletion into OpenSim function --- app/OpenSim.php | 17 +++++++++++++++++ pages/identities.php | 9 ++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/OpenSim.php b/app/OpenSim.php index ff628e8..88b6f38 100644 --- a/app/OpenSim.php +++ b/app/OpenSim.php @@ -267,6 +267,23 @@ } } + public function deleteIdentity($uuid, $identId): bool + { + global $RUNTIME; + + $statementValidate = $RUNTIME['PDO']->prepare('SELECT 1 FROM UserIdentitys WHERE PrincipalID = ? AND IdentityID = ?'); + $statementValidate->execute([$uuid, $identId]); + + if($statementValidate->fetch()) { + $statementDelete = $RUNTIME['PDO']->prepare('DELETE FROM UserAccounts WHERE PrincipalID = ?'); + $statementDelete->execute([$identId]); + + return true; + } + + return false; + } + public function gen_uuid() { return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', diff --git a/pages/identities.php b/pages/identities.php index 9cd809d..c2d6f7f 100644 --- a/pages/identities.php +++ b/pages/identities.php @@ -89,13 +89,8 @@ )); if ($validator->isValid($_POST)) { - $statementValidate = $RUNTIME['PDO']->prepare('SELECT 1 FROM UserIdentitys WHERE PrincipalID = ? AND IdentityID = ?'); - $statementValidate->execute([$_SESSION['UUID'], $_POST['uuid']]); - - if($statementValidate->fetch()) { - $statementDelete = $RUNTIME['PDO']->prepare('DELETE FROM UserAccounts WHERE PrincipalID = ?'); - $statementDelete->execute([$_POST['uuid']]); - } + include_once 'app/OpenSim.php'; + (new OpenSim())->deleteIdentity($_SESSION['UUID'], $_POST['uuid']); } }