Skip to content

Commit e901503

Browse files
committed
fix: prevent load empty entity when have an entity
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 2edf947 commit e901503

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

lib/Service/IdentifyMethodService.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public function getInstanceOfIdentifyMethod(string $name, ?string $identifyValue
7575
if ($identifyValue && isset($this->identifyMethods[$name])) {
7676
foreach ($this->identifyMethods[$name] as $identifyMethod) {
7777
if ($identifyMethod->getEntity()->getIdentifierValue() === $identifyValue) {
78+
$identifyValue = $this->mergeWithCurrentIdentifyMethod($identifyMethod);
7879
return $identifyMethod;
7980
}
8081
}
@@ -95,6 +96,18 @@ public function getInstanceOfIdentifyMethod(string $name, ?string $identifyValue
9596
return $identifyMethod;
9697
}
9798

99+
private function mergeWithCurrentIdentifyMethod(IIdentifyMethod $identifyMethod): IIdentifyMethod {
100+
if ($this->currentIdentifyMethod === null) {
101+
return $identifyMethod;
102+
}
103+
if ($this->currentIdentifyMethod->getIdentifierKey() === $identifyMethod->getEntity()->getIdentifierKey()
104+
&& $this->currentIdentifyMethod->getIdentifierValue() === $identifyMethod->getEntity()->getIdentifierValue()
105+
) {
106+
$identifyMethod->setEntity($this->currentIdentifyMethod);
107+
}
108+
return $identifyMethod;
109+
}
110+
98111
private function getNewInstanceOfMethod(string $name): IIdentifyMethod {
99112
$className = 'OCA\Libresign\Service\IdentifyMethod\\' . ucfirst($name);
100113
if (!class_exists($className)) {

0 commit comments

Comments
 (0)