Skip to content

Commit

Permalink
Validate password before hash it
Browse files Browse the repository at this point in the history
  • Loading branch information
MoamenEltouny committed Dec 13, 2022
1 parent fcb5ced commit b005cc4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Traits/Password/HasHashedPassword.php
Expand Up @@ -19,11 +19,12 @@ trait HasHashedPassword
public static function bootHasHashedPassword()
{
self::creating(function ($model) {
$model->password = Hash::make($model->password);
if (!empty($model->password))
$model->password = Hash::make($model->password);
});

self::updating(function ($model) {
if ($model->isDirty('password')) {
if ($model->isDirty('password') && !empty($model->password)) {
$model->password = Hash::make($model->password);
}
});
Expand Down

0 comments on commit b005cc4

Please sign in to comment.