Skip to content

Commit

Permalink
Added a password upgrade mechanism when PHP considers useful
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianLeChat committed May 24, 2024
1 parent 1bb843c commit ef2f21f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 2 additions & 4 deletions phpmd.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<ruleset xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
>
<ruleset xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<rule ref="rulesets/design.xml">
<!-- Utilisation d'expressions try/catch vides -->
<exclude name="EmptyCatchBlock" />
Expand Down Expand Up @@ -49,6 +46,7 @@
<!-- Exécution de méthodes ayant une complexité importante -->
<exclude name="NPathComplexity" />
<exclude name="CyclomaticComplexity" />
<exclude name="ExcessiveClassComplexity" />

<!-- Voir la règle définie « TooManyPublicMethods » -->
<exclude name="TooManyPublicMethods" />
Expand Down
7 changes: 7 additions & 0 deletions src/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ public function login(Request $request): Response
$user = $this->getUser();
$user->setAddress($request->getClientIp());

if ($this->hasher->needsRehash($user))
{
// Mise à jour du hachage du mot de passe de l'utilisateur
// si nécessaire.
$user->setPassword($this->hasher->hashPassword($user, $password));
}

$repository->save($user, true);

// On envoie enfin la réponse au client.
Expand Down

0 comments on commit ef2f21f

Please sign in to comment.