mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
add account balances with some random data
This commit is contained in:
59
app/Policies/AccountBalancePolicy.php
Normal file
59
app/Policies/AccountBalancePolicy.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/*
|
||||
* AccountPolicy.php
|
||||
* Copyright (c) 2024 james@firefly-iii.org.
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Policies;
|
||||
|
||||
use FireflyIII\Entities\AccountBalance;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\User;
|
||||
|
||||
class AccountBalancePolicy
|
||||
{
|
||||
|
||||
/**
|
||||
* TODO needs better authentication.
|
||||
*
|
||||
* @param User $user
|
||||
* @param Account $account
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function view(User $user, AccountBalance $accountBalance): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Everybody can do this, but selection should limit to user.
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
public function viewAny(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -43,6 +43,8 @@ class AccountPolicy
|
||||
return auth()->check() && $user->id === $account->user_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Everybody can do this, but selection should limit to user.
|
||||
*
|
||||
@@ -64,7 +66,7 @@ class AccountPolicy
|
||||
return $this->view($user, $account);
|
||||
}
|
||||
|
||||
public function viewBalances(User $user, Account $account): bool
|
||||
public function viewAccountBalances(User $user, Account $account): bool
|
||||
{
|
||||
return $this->view($user, $account);
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ class UserPolicy
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function view(User $user, Account $account): bool
|
||||
public function view(User $user, User $user1): bool
|
||||
{
|
||||
return true;
|
||||
return auth()->check() && $user->id === $account->user_id;
|
||||
@@ -52,4 +52,9 @@ class UserPolicy
|
||||
return true;
|
||||
return auth()->check();
|
||||
}
|
||||
public function viewAccounts(User $user): bool
|
||||
{
|
||||
return true;
|
||||
return auth()->check();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user