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 authored 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
Original file line number Diff line number Diff line change
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.