From 10597e3befd023239ba4481c9ed459bf33006a62 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 12 Jun 2021 08:40:35 +0200 Subject: [PATCH] Clean up code. --- app/Ldap/AttributeHandler.php | 41 +++++++++++++++++++ .../TransactionGroupRepository.php | 4 +- .../Http/Controllers/RenderPartialViews.php | 4 +- config/auth.php | 6 +-- 4 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 app/Ldap/AttributeHandler.php diff --git a/app/Ldap/AttributeHandler.php b/app/Ldap/AttributeHandler.php new file mode 100644 index 0000000000..f8b025e6ef --- /dev/null +++ b/app/Ldap/AttributeHandler.php @@ -0,0 +1,41 @@ +. + */ + +namespace FireflyIII\Ldap; + +use FireflyIII\User as DatabaseUser; +use LdapRecord\Models\OpenLDAP\User as LdapUser; + +/** + * Class AttributeHandler + */ +class AttributeHandler +{ + /** + * @param LdapUser $ldap + * @param DatabaseUser $database + */ + public function handle(LdapUser $ldap, DatabaseUser $database) + { + $database->email = $ldap->getFirstAttribute('mail'); + $database->save(); + } +} \ No newline at end of file diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.php index a49f5d531e..1f588c20b4 100644 --- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php +++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php @@ -398,9 +398,9 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface $array['categories'] = $journal->categories->toArray(); $array['budgets'] = $journal->budgets->toArray(); $array['notes'] = $journal->notes->toArray(); - $array['locations'] = []; // todo + $array['locations'] = []; $array['attachments'] = $journal->attachments->toArray(); - $array['links'] = []; // todo + $array['links'] = []; $array['piggy_bank_events'] = $journal->piggyBankEvents->toArray(); /** @var Transaction $transaction */ diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.php index 2258a175e5..8aa97bdb95 100644 --- a/app/Support/Http/Controllers/RenderPartialViews.php +++ b/app/Support/Http/Controllers/RenderPartialViews.php @@ -255,7 +255,7 @@ trait RenderPartialViews { $index = 0; $actions = []; - // todo must be repos + // must be repos $currentActions = $rule->ruleActions()->orderBy('order', 'ASC')->get(); /** @var RuleAction $entry */ foreach ($currentActions as $entry) { @@ -304,7 +304,7 @@ trait RenderPartialViews asort($triggers); $index = 0; $renderedEntries = []; - // todo must be repos + // must be repos $currentTriggers = $rule->ruleTriggers()->orderBy('order', 'ASC')->get(); /** @var RuleTrigger $entry */ foreach ($currentTriggers as $entry) { diff --git a/config/auth.php b/config/auth.php index 09c2b6e5b0..e9fa206dd4 100644 --- a/config/auth.php +++ b/config/auth.php @@ -21,6 +21,8 @@ declare(strict_types=1); +use FireflyIII\Ldap\AttributeHandler; + return [ /* |-------------------------------------------------------------------------- @@ -111,9 +113,7 @@ return [ 'database' => [ 'model' => FireflyIII\User::class, 'sync_passwords' => false, - 'sync_attributes' => [ - 'email' => 'mail', - ], + 'sync_attributes' => AttributeHandler::class, ], ], ],