Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Add generic types #67

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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