Skip to content

Commit 094c498

Browse files
committed
fix: Properly reformat gmails
1 parent fd2eeed commit 094c498

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Helper/UserDataHelper.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class UserDataHelper
1313
public function addEmail(string $email): int
1414
{
1515
// Sanitize & Validate email
16-
$email = str_replace(" ", "", $email);
16+
$email = str_replace(" ", "", mb_strtolower($email));
1717
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) return -1; // Invalid email format
1818

1919
// Google Mail Sanitizer
@@ -28,16 +28,15 @@ public function addEmail(string $email): int
2828
$x[1] = "gmail.com"; //
2929
}
3030
$x[0] = explode("+", $x[0], 2)[0]; // https://gmail.googleblog.com/2008/03/2-hidden-ways-to-get-more-from-your.html
31-
$x[0] = str_replace($x[0], ".", "");
31+
$x[0] = str_replace(".", "", $x[0]);
3232
$email = implode("@", $x);
3333
}
3434

3535
// Sha256 encode
36-
$email = hash("sha256", mb_strtolower($email));
36+
$email = hash("sha256", $email);
3737

38-
// Append email to user
39-
array_push($this->sha256_email_address, $email);
40-
$this->sha256_email_address = array_unique($this->sha256_email_address);
41-
return array_search($email, $this->sha256_email_address, true);
38+
// Skip duplicated and append email
39+
$this->sha256_email_address = array_filter($this->sha256_email_address, fn ($v) => $v != $email);
40+
return array_push($this->sha256_email_address, $email) - 1;
4241
}
4342
}

0 commit comments

Comments
 (0)