mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
fix identity match function
This commit is contained in:
parent
f6812c9dc2
commit
555f08e59b
1 changed files with 34 additions and 6 deletions
|
|
@ -36,7 +36,7 @@ class Gemini
|
||||||
$options = $request->getOptions();
|
$options = $request->getOptions();
|
||||||
|
|
||||||
// Apply identity if available
|
// Apply identity if available
|
||||||
if ($identity = $this->matchIdentity($address->get()))
|
if ($identity = $this->matchIdentity($address))
|
||||||
{
|
{
|
||||||
$crt = tmpfile();
|
$crt = tmpfile();
|
||||||
|
|
||||||
|
|
@ -373,18 +373,46 @@ class Gemini
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function matchIdentity(
|
public function matchIdentity(
|
||||||
string $request,
|
Address $address,
|
||||||
array $identities = []
|
array $identities = []
|
||||||
): ?object
|
): ?object
|
||||||
{
|
{
|
||||||
foreach ($this->_connection->database->auth->like(sprintf('%s%%', $request)) as $auth)
|
foreach (
|
||||||
{
|
// Select host records
|
||||||
$identities[$auth->identity] = $auth->request;
|
$this->_connection->database->auth->like(
|
||||||
|
sprintf(
|
||||||
|
'%s%%',
|
||||||
|
$address->get(
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) as $auth
|
||||||
|
) {
|
||||||
|
// Parse result address
|
||||||
|
$request = new Address(
|
||||||
|
$auth->request
|
||||||
|
);
|
||||||
|
|
||||||
|
// Filter results match current path prefix
|
||||||
|
if (str_starts_with($address->getPath(), $request->getPath()))
|
||||||
|
{
|
||||||
|
$identities[
|
||||||
|
$auth->identity
|
||||||
|
] = $auth->request;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Results found
|
||||||
if ($identities)
|
if ($identities)
|
||||||
{
|
{
|
||||||
uasort(
|
uasort( // max-level
|
||||||
$identities,
|
$identities,
|
||||||
function ($a, $b)
|
function ($a, $b)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue