mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +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();
|
]->useName();
|
||||||
|
|
||||||
// Search database for auth records
|
// Search database for auth records
|
||||||
foreach ($this->page->container->browser->database->auth->like(
|
foreach ($this->page->container->browser->database->auth->match(
|
||||||
sprintf(
|
sprintf(
|
||||||
'%s%%',
|
'%s%%',
|
||||||
$this->page->navbar->request->getValue()
|
$this->page->navbar->request->getValue()
|
||||||
|
|
@ -202,6 +202,11 @@ class Auth
|
||||||
// Init identity model
|
// Init identity model
|
||||||
$identity = new Gemini;
|
$identity = new Gemini;
|
||||||
|
|
||||||
|
// Logout previous set
|
||||||
|
$this->page->container->browser->database->auth->logout(
|
||||||
|
$this->page->navbar->request->getValue()
|
||||||
|
);
|
||||||
|
|
||||||
// Add new auth record
|
// Add new auth record
|
||||||
$this->page->container->browser->database->auth->add(
|
$this->page->container->browser->database->auth->add(
|
||||||
$this->page->container->browser->database->identity->add(
|
$this->page->container->browser->database->identity->add(
|
||||||
|
|
|
||||||
|
|
@ -98,37 +98,8 @@ class Auth
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find(
|
public function match(
|
||||||
string $request = '',
|
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 = '',
|
|
||||||
int $start = 0,
|
int $start = 0,
|
||||||
int $limit = 1000
|
int $limit = 1000
|
||||||
): array
|
): array
|
||||||
|
|
@ -152,4 +123,20 @@ class Auth
|
||||||
|
|
||||||
return $query->fetchAll();
|
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