mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
implement logout method
This commit is contained in:
parent
daf048d25b
commit
f901bff995
2 changed files with 24 additions and 32 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue