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']); } }