mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Update translations and fix some code.
This commit is contained in:
@@ -31,6 +31,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
use JsonException;
|
||||
|
||||
@@ -128,10 +129,13 @@ class NetWorth implements NetWorthInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param User|Authenticatable|null $user
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
public function setUser(User|Authenticatable|null $user): void
|
||||
{
|
||||
if (null === $user) {
|
||||
return;
|
||||
}
|
||||
$this->user = $user;
|
||||
|
||||
// make repository:
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace FireflyIII\Helpers\Report;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@@ -54,9 +55,9 @@ interface NetWorthInterface
|
||||
public function getNetWorthByCurrency(Collection $accounts, Carbon $date): array;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param User|Authenticatable|null $user
|
||||
*/
|
||||
public function setUser(User $user): void;
|
||||
public function setUser(User|Authenticatable|null $user): void;
|
||||
|
||||
/**
|
||||
* TODO move to repository
|
||||
|
||||
@@ -42,7 +42,7 @@ class Authenticate
|
||||
*
|
||||
* @var Auth
|
||||
*/
|
||||
protected $auth;
|
||||
protected Auth $auth;
|
||||
|
||||
/**
|
||||
* Create a new middleware instance.
|
||||
@@ -101,7 +101,8 @@ class Authenticate
|
||||
$this->validateBlockedUser($user, $guards);
|
||||
}
|
||||
|
||||
return $this->auth->authenticate(); // @phpstan-ignore-line (thinks function returns void)
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
return $this->auth->authenticate();
|
||||
}
|
||||
Log::debug('Guard array is not empty.');
|
||||
|
||||
@@ -146,6 +147,7 @@ class Authenticate
|
||||
}
|
||||
Log::warning('User is blocked, cannot use authentication method.');
|
||||
app('session')->flash('logoutMessage', $message);
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
$this->auth->logout(); // @phpstan-ignore-line (thinks function is undefined)
|
||||
|
||||
throw new AuthenticationException('Blocked account.', $guards);
|
||||
|
||||
@@ -128,7 +128,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$dbQuery->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');
|
||||
$dbQuery->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
/** @var Account|null */
|
||||
return $dbQuery->first(['accounts.*']);
|
||||
}
|
||||
|
||||
@@ -147,6 +147,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
$query->whereIn('account_types.type', $types);
|
||||
}
|
||||
|
||||
/** @var Account|null */
|
||||
return $query->where('iban', $iban)->first(['accounts.*']);
|
||||
}
|
||||
|
||||
@@ -330,6 +331,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*/
|
||||
public function getLocation(Account $account): ?Location
|
||||
{
|
||||
/** @var Location|null */
|
||||
return $account->locations()->first();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ use FireflyIII\Models\InvitedUser;
|
||||
use FireflyIII\Models\Role;
|
||||
use FireflyIII\Models\UserGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
@@ -280,27 +281,30 @@ class UserRepository implements UserRepositoryInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param User|Authenticatable|null $user
|
||||
* @param string $role
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasRole(User $user, string $role): bool
|
||||
{
|
||||
/** @var Role $userRole */
|
||||
foreach ($user->roles as $userRole) {
|
||||
if ($userRole->name === $role) {
|
||||
return true;
|
||||
public function hasRole(User|Authenticatable|null $user, string $role): bool
|
||||
{
|
||||
if (null === $user) {
|
||||
return false;
|
||||
}
|
||||
/** @var Role $userRole */
|
||||
foreach ($user->roles as $userRole) {
|
||||
if ($userRole->name === $role) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function inviteUser(User $user, string $email): InvitedUser
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function inviteUser(User|Authenticatable|null $user, string $email): InvitedUser
|
||||
{
|
||||
$now = today(config('app.timezone'));
|
||||
$now->addDays(2);
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace FireflyIII\Repositories\User;
|
||||
use FireflyIII\Models\InvitedUser;
|
||||
use FireflyIII\Models\Role;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@@ -165,19 +166,19 @@ interface UserRepositoryInterface
|
||||
public function getUserData(User $user): array;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param User|Authenticatable|null $user
|
||||
* @param string $role
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasRole(User $user, string $role): bool;
|
||||
public function hasRole(User|Authenticatable|null $user, string $role): bool;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param User|Authenticatable|null $user
|
||||
* @param string $email
|
||||
* @return InvitedUser
|
||||
*/
|
||||
public function inviteUser(User $user, string $email): InvitedUser;
|
||||
public function inviteUser(User|Authenticatable|null $user, string $email): InvitedUser;
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
|
||||
Reference in New Issue
Block a user