chore (login) #43 : remaniement connexion sql, passage à 1 requête au lieu de 2 pour performances
This commit is contained in:
@ -72,33 +72,37 @@ class SQLLoginRequest
|
||||
return $this->config[self::SUBJECT_REWRITE_EXPRESSION];
|
||||
}
|
||||
|
||||
public function getRequestScope(): string
|
||||
private function getDataFields(): array
|
||||
{
|
||||
$scope = '';
|
||||
if (!$this->config[self::DATA_TO_FETCH]) {
|
||||
throw new NullDataToFetchException();
|
||||
}
|
||||
|
||||
foreach ($this->config[self::DATA_TO_FETCH] as $data) {
|
||||
$scope .= $data.',';
|
||||
}
|
||||
// On enlève la dernière virgule
|
||||
$scope = substr($scope, 0, -1);
|
||||
|
||||
return 'SELECT '.$scope.' FROM '.$this->getTableName().' WHERE '.$this->getLoginColumnName().' = :'.$this->getLoginColumnName().';';
|
||||
return $this->config[self::DATA_TO_FETCH];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construction de la string pour la requête préparée selon la configuration yaml
|
||||
* intègre la récupération du mot de passe hashé, du salt et de besoin d'upgrade de la méthode de hashage
|
||||
*/
|
||||
public function getRequestPassword(): string
|
||||
private function getPasswordFields(): array
|
||||
{
|
||||
$fields = $this->getPasswordColumnName();
|
||||
$fields[] = $this->getPasswordColumnName();
|
||||
if (!empty($this->getSaltColumnName())) {
|
||||
$fields .= ', '.$this->getSaltColumnName();
|
||||
$fields[] = $this->getSaltColumnName();
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construction de la string pour la requête préparée selon la configuration yaml
|
||||
* intègre la récupération du mot de passe hashé, du salt et de besoin d'upgrade de la méthode de hashage
|
||||
*/
|
||||
public function getDatasRequest(): string
|
||||
{
|
||||
$fields = join(',', array_merge($this->getPasswordFields(), $this->getDataFields()));
|
||||
|
||||
return 'SELECT '.$fields.' FROM '.$this->getTableName().' WHERE '.$this->getLoginColumnName().' = :'.$this->getLoginColumnName().';';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user