Skip to content

Commit da2a739

Browse files
authored
Update HasPassword.php
If hashed password is posted, ensure we do not try to hash that value
1 parent 2f0472d commit da2a739

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Traits/HasPassword.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ public static function bootHasPassword(){
1616
static::updating(function($model) {
1717
$passwordFieldName = $model->getPasswordFieldName();
1818
$modelMutator = new ModelMutator($model);
19-
if(!empty($model->$passwordFieldName)){
19+
$currentHashedPassword = $model->getOriginal('password');
20+
if(!empty($model->$passwordFieldName) && $model->$passwordFieldName != $currentHashedPassword){
2021
$model = $modelMutator->hashPassword($passwordFieldName)->getModel();
22+
}else{
23+
unset($model->password);
2124
}
2225
});
2326
}
@@ -29,4 +32,4 @@ public function getPasswordFieldName(){
2932
return 'password';
3033
}
3134

32-
}
35+
}

0 commit comments

Comments
 (0)