Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 308ac0a

Browse files
committed
Added password key config option
1 parent 43519f5 commit 308ac0a

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/AdldapAuthUserProvider.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ public function retrieveByCredentials(array $credentials)
6161
$username = Arr::get($username, 0);
6262
}
6363

64+
// Get the password input array key.
65+
$key = $this->getPasswordKey();
66+
6467
// Try to log the user in.
65-
if($this->authenticate($username, $credentials['password'])) {
68+
if($this->authenticate($username, $credentials[$key])) {
6669
// Login was successful, we'll create a new
6770
// Laravel model with the Adldap user.
68-
return $this->getModelFromAdldap($user, $credentials['password']);
71+
return $this->getModelFromAdldap($user, $credentials[$key]);
6972
}
7073
}
7174

@@ -246,6 +249,17 @@ protected function getUsernameAttribute()
246249
return Config::get('adldap_auth.username_attribute', ['username' => ActiveDirectory::ACCOUNT_NAME]);
247250
}
248251

252+
/**
253+
* Returns the password key to retrieve the
254+
* password from the user input array.
255+
*
256+
* @return mixed
257+
*/
258+
protected function getPasswordKey()
259+
{
260+
return Config::get('adldap_auth.password_key', 'password');
261+
}
262+
249263
/**
250264
* Retrieves the Adldap login attribute for authenticating users.
251265
*

src/Config/auth.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@
2121

2222
'username_attribute' => ['username' => 'samaccountname'],
2323

24+
/*
25+
|--------------------------------------------------------------------------
26+
| Password Key
27+
|--------------------------------------------------------------------------
28+
|
29+
| The password key is the name of the input array key located inside
30+
| the user input array given to the auth driver.
31+
|
32+
| Change this if you change your password fields input name.
33+
|
34+
*/
35+
36+
'password_key' => 'password',
37+
2438
/*
2539
|--------------------------------------------------------------------------
2640
| Login Attribute

0 commit comments

Comments
 (0)