fix(user): ensure email attributes are stored in lowercase for consistency and prevent case-related issues
This commit is contained in:
@@ -40,7 +40,7 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
$user = User::create([
|
$user = User::create([
|
||||||
'id' => 0,
|
'id' => 0,
|
||||||
'name' => $input['name'],
|
'name' => $input['name'],
|
||||||
'email' => strtolower($input['email']),
|
'email' => $input['email'],
|
||||||
'password' => Hash::make($input['password']),
|
'password' => Hash::make($input['password']),
|
||||||
]);
|
]);
|
||||||
$team = $user->teams()->first();
|
$team = $user->teams()->first();
|
||||||
@@ -52,7 +52,7 @@ class CreateNewUser implements CreatesNewUsers
|
|||||||
} else {
|
} else {
|
||||||
$user = User::create([
|
$user = User::create([
|
||||||
'name' => $input['name'],
|
'name' => $input['name'],
|
||||||
'email' => strtolower($input['email']),
|
'email' => $input['email'],
|
||||||
'password' => Hash::make($input['password']),
|
'password' => Hash::make($input['password']),
|
||||||
]);
|
]);
|
||||||
$team = $user->teams()->first();
|
$team = $user->teams()->first();
|
||||||
|
@@ -78,6 +78,8 @@ class Index extends Component
|
|||||||
'new_email' => ['required', 'email', 'unique:users,email'],
|
'new_email' => ['required', 'email', 'unique:users,email'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->new_email = strtolower($this->new_email);
|
||||||
|
|
||||||
// Skip rate limiting in development mode
|
// Skip rate limiting in development mode
|
||||||
if (! isDev()) {
|
if (! isDev()) {
|
||||||
// Rate limit by current user's email (1 request per 2 minutes)
|
// Rate limit by current user's email (1 request per 2 minutes)
|
||||||
@@ -90,7 +92,7 @@ class Index extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Rate limit by new email address (3 requests per hour per email)
|
// Rate limit by new email address (3 requests per hour per email)
|
||||||
$newEmailKey = 'email-change:email:'.md5(strtolower($this->new_email));
|
$newEmailKey = 'email-change:email:'.md5($this->new_email);
|
||||||
if (! RateLimiter::attempt($newEmailKey, 3, function () {}, 3600)) {
|
if (! RateLimiter::attempt($newEmailKey, 3, function () {}, 3600)) {
|
||||||
$this->dispatch('error', 'This email address has received too many verification requests. Please try again later.');
|
$this->dispatch('error', 'This email address has received too many verification requests. Please try again later.');
|
||||||
|
|
||||||
|
@@ -56,6 +56,22 @@ class User extends Authenticatable implements SendsEmail
|
|||||||
'email_change_code_expires_at' => 'datetime',
|
'email_change_code_expires_at' => 'datetime',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the email attribute to lowercase.
|
||||||
|
*/
|
||||||
|
public function setEmailAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['email'] = strtolower($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the pending_email attribute to lowercase.
|
||||||
|
*/
|
||||||
|
public function setPendingEmailAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['pending_email'] = $value ? strtolower($value) : null;
|
||||||
|
}
|
||||||
|
|
||||||
protected static function boot()
|
protected static function boot()
|
||||||
{
|
{
|
||||||
parent::boot();
|
parent::boot();
|
||||||
|
Reference in New Issue
Block a user