diff --git a/src/Entity/Browser/Container/Page/Auth.php b/src/Entity/Browser/Container/Page/Auth.php index 7edca4cf..cad964a9 100644 --- a/src/Entity/Browser/Container/Page/Auth.php +++ b/src/Entity/Browser/Container/Page/Auth.php @@ -97,7 +97,7 @@ class Auth ]->useName(); // Search database for auth records - foreach ($this->page->container->browser->database->auth->like( + foreach ($this->page->container->browser->database->auth->match( sprintf( '%s%%', $this->page->navbar->request->getValue() @@ -202,6 +202,11 @@ class Auth // Init identity model $identity = new Gemini; + // Logout previous set + $this->page->container->browser->database->auth->logout( + $this->page->navbar->request->getValue() + ); + // Add new auth record $this->page->container->browser->database->auth->add( $this->page->container->browser->database->identity->add( diff --git a/src/Model/Database/Auth.php b/src/Model/Database/Auth.php index 69df8b83..a2f495ca 100644 --- a/src/Model/Database/Auth.php +++ b/src/Model/Database/Auth.php @@ -98,37 +98,8 @@ class Auth return null; } - public function find( - string $request = '', - int $start = 0, - int $limit = 1000 - ): array - { - $query = $this->_connection->prepare( - sprintf( - 'SELECT * FROM `auth` - WHERE `request` LIKE :request - ORDER BY `request` ASC - LIMIT %d,%d', - $start, - $limit - ) - ); - - $query->execute( - [ - ':request' => sprintf( - '%%%s%%', - $request - ) - ] - ); - - return $query->fetchAll(); - } - - public function like( - string $request = '', + public function match( + string $request = '', int $start = 0, int $limit = 1000 ): array @@ -152,4 +123,20 @@ class Auth return $query->fetchAll(); } + + public function logout( + string $request + ): int + { + $records = 0; + + foreach ($this->match($request) as $record) + { + $records += $this->delete( + $record->id + ); + } + + return $records; + } } \ No newline at end of file