mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-04 03:43:07 +00:00
Group filter for #5133
This commit is contained in:
30
app/Ldap/Rules/UserDefinedRule.php
Normal file
30
app/Ldap/Rules/UserDefinedRule.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Ldap\Rules;
|
||||
|
||||
use LdapRecord\Laravel\Auth\Rule;
|
||||
use LdapRecord\Models\ActiveDirectory\Group;
|
||||
|
||||
/**
|
||||
* Class UserDefinedRule
|
||||
*/
|
||||
class UserDefinedRule extends Rule
|
||||
{
|
||||
/**
|
||||
* Check if the rule passes validation.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isValid()
|
||||
{
|
||||
// LDAP_GROUP_FILTER
|
||||
$groupFilter = config('ldap.group_filter');
|
||||
if (null !== $groupFilter && '' !== (string)$groupFilter) {
|
||||
$administrators = Group::find('cn=Administrators,dc=local,dc=com');
|
||||
|
||||
return $this->user->groups()->recursive()->exists($administrators);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user