Skip to content

Commit

Permalink
PR feedback: rewrite domain mask for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
briskt committed Dec 10, 2024
1 parent 8c80b6d commit ad9ee0f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions modules/mfa/src/Auth/Process/Mfa.php
Original file line number Diff line number Diff line change
Expand Up @@ -912,9 +912,16 @@ public static function maskEmail(string $email): string
* Add an '*' for each of the characters of the domain, except
* for the first character of each part and the .
*/
$newEmail .= implode('.', array_map(function ($part) {
return substr($part, 0, 1) . str_repeat('*', max(strlen($part) - 1, 0));
}, explode('.', $domain)));
$domainParts = explode('.', $domain);
$maskedDomain = '';

foreach ($domainParts as $part) {
$firstCharacter = substr($part, 0, 1);
$maskedPart = $firstCharacter . str_repeat('*', max(strlen($part) - 1, 0));
$maskedDomain .= $maskedPart . '.';
}
$maskedDomain = rtrim($maskedDomain, '.');
$newEmail .= $maskedDomain;
return $newEmail;
}

Expand Down

0 comments on commit ad9ee0f

Please sign in to comment.