Skip to content

Commit f8cb5c9

Browse files
authored
Merge pull request #556 from DirectoryTree/revert-506
Revert #506
2 parents bb42c75 + fb5a980 commit f8cb5c9

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/Models/Concerns/HasPassword.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,10 @@ protected function setChangedPassword($oldPassword, $newPassword, $attribute)
144144
*/
145145
protected function setPassword($password, $attribute)
146146
{
147-
$modtype = $this->exists
148-
? LDAP_MODIFY_BATCH_REPLACE
149-
: LDAP_MODIFY_BATCH_ADD;
150-
151147
$this->addModification(
152148
$this->newBatchModification(
153149
$attribute,
154-
$modtype,
150+
LDAP_MODIFY_BATCH_REPLACE,
155151
[$password]
156152
)
157153
);

tests/Unit/Models/ActiveDirectory/UserTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use LdapRecord\Models\Attributes\AccountControl;
1212
use LdapRecord\Models\Attributes\Password;
1313
use LdapRecord\Models\Attributes\Timestamp;
14+
use LdapRecord\Models\Concerns\HasPassword;
1415
use LdapRecord\Models\Model;
1516
use LdapRecord\Tests\TestCase;
1617

@@ -56,7 +57,7 @@ public function test_set_password_on_new_user()
5657

5758
$this->assertEquals([
5859
'attrib' => 'unicodepwd',
59-
'modtype' => LDAP_MODIFY_BATCH_ADD,
60+
'modtype' => LDAP_MODIFY_BATCH_REPLACE,
6061
'values' => [Password::encode('foo')],
6162
], $mods[0]);
6263
}
@@ -78,15 +79,15 @@ public function test_set_password_on_existing_user()
7879
], $mods[0]);
7980
}
8081

81-
public function test_set_password_behaves_identically_on_non_user_models()
82+
public function test_set_password_behaves_differently_on_non_user_models()
8283
{
8384
$user = new UserPasswordTestStub();
8485

8586
$user->unicodepwd = 'foo';
8687

8788
$nonUser = new NonUserPasswordTestStub();
8889

89-
$nonUser->unicodepwd = Password::encode('foo');
90+
$nonUser->unicodepwd = 'foo';
9091

9192
$this->assertEquals($user->getModifications(), $nonUser->getModifications());
9293
}
@@ -244,6 +245,12 @@ protected function validateSecureConnection()
244245

245246
class NonUserPasswordTestStub extends Model
246247
{
248+
use HasPassword;
249+
250+
protected $passwordAttribute = 'unicodepwd';
251+
252+
protected $passwordHashMethod = 'encode';
253+
247254
protected function validateSecureConnection()
248255
{
249256
return true;

0 commit comments

Comments
 (0)