Skip to content

Commit

Permalink
ENH Add generic types
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jan 18, 2024
1 parent 8226c4b commit f22e75e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
3 changes: 0 additions & 3 deletions src/Authenticators/LDAPAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public static function get_login_form(Controller $controller)
public function authenticate(array $data, HTTPRequest $request, ValidationResult &$result = null)
{
$result = $result ?: ValidationResult::create();
/** @var LDAPService $service */
$service = Injector::inst()->get(LDAPService::class);
$login = trim($data['Login'] ?? '');
if (Email::is_valid_address($login)) {
Expand Down Expand Up @@ -224,13 +223,11 @@ public function checkPassword(Member $member, $password, ValidationResult &$resu
{
$result = $result ?: ValidationResult::create();

/** @var LDAPService $service */
$service = Injector::inst()->get(LDAPService::class);

// Support email or username
$handle = Config::inst()->get(self::class, 'allow_email_login') === 'yes' ? 'Email' : 'Username';

/** @var array $ldapResult */
$ldapResult = $service->authenticate($member->{$handle}, $password);

if (empty($ldapResult['success'])) {
Expand Down
3 changes: 3 additions & 0 deletions src/Control/LDAPDebugController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace SilverStripe\LDAP\Control;

use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Core\Config\Config;
use SilverStripe\LDAP\Model\LDAPGateway;
Expand All @@ -18,6 +19,8 @@
* Class LDAPDebugController
*
* This controller is used to debug the LDAP connection.
*
* @extends ContentController<SiteTree>
*/
class LDAPDebugController extends ContentController
{
Expand Down
3 changes: 3 additions & 0 deletions src/Extensions/LDAPGroupExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
* Class LDAPGroupExtension
*
* Adds a field to map an LDAP group to a SilverStripe {@link Group}
*
* @method SilverStripe\ORM\HasManyList<LDAPGroupMapping> LDAPGroupMappings()
*
* @extends DataExtension<Group&static>
*/
class LDAPGroupExtension extends DataExtension
{
Expand Down
3 changes: 2 additions & 1 deletion src/Extensions/LDAPMemberExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
use SilverStripe\ORM\DataExtension;
use SilverStripe\ORM\ValidationException;
use SilverStripe\ORM\ValidationResult;
use SilverStripe\Security\Member;

/**
* Class LDAPMemberExtension.
*
* Adds mappings from AD attributes to SilverStripe {@link Member} fields.
*
* @package activedirectory
* @extends DataExtension<Member>
*/
class LDAPMemberExtension extends DataExtension
{
Expand Down
1 change: 0 additions & 1 deletion src/Services/LDAPService.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ public static function get_cache()
*/
public static function flush()
{
/** @var CacheInterface $cache */
$cache = self::get_cache();
$cache->clear();
}
Expand Down

0 comments on commit f22e75e

Please sign in to comment.