Update translations and fix some code.

This commit is contained in:
James Cole
2023-02-22 19:54:19 +01:00
parent a18cd23154
commit 585cfddfd7
40 changed files with 343 additions and 328 deletions

View File

@@ -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);

View File

@@ -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