2016-03-12 14:18:28 +01:00
|
|
|
<?php
|
2022-12-29 19:42:26 +01:00
|
|
|
|
2016-03-12 14:18:28 +01:00
|
|
|
/**
|
|
|
|
* UserRepositoryInterface.php
|
2020-02-16 14:00:57 +01:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2016-03-12 14:18:28 +01:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2016-10-05 06:52:15 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* 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.
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2017-10-21 08:40:00 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-02 06:37:26 +02:00
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* 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/>.
|
2016-03-12 14:18:28 +01:00
|
|
|
*/
|
2017-03-24 15:01:53 +01:00
|
|
|
declare(strict_types=1);
|
2016-05-20 12:41:23 +02:00
|
|
|
|
2016-03-12 14:18:28 +01:00
|
|
|
namespace FireflyIII\Repositories\User;
|
|
|
|
|
2022-10-01 12:21:42 +02:00
|
|
|
use FireflyIII\Models\InvitedUser;
|
2018-01-21 18:06:57 +01:00
|
|
|
use FireflyIII\Models\Role;
|
2016-03-12 14:18:28 +01:00
|
|
|
use FireflyIII\User;
|
2023-02-22 19:54:19 +01:00
|
|
|
use Illuminate\Contracts\Auth\Authenticatable;
|
2016-04-03 07:07:17 +02:00
|
|
|
use Illuminate\Support\Collection;
|
2016-03-12 14:18:28 +01:00
|
|
|
|
|
|
|
/**
|
2017-11-15 12:25:49 +01:00
|
|
|
* Interface UserRepositoryInterface.
|
2016-03-12 14:18:28 +01:00
|
|
|
*/
|
|
|
|
interface UserRepositoryInterface
|
|
|
|
{
|
2016-04-03 07:07:17 +02:00
|
|
|
/**
|
2016-04-26 08:09:10 +02:00
|
|
|
* Returns a collection of all users.
|
2016-04-03 07:07:17 +02:00
|
|
|
*/
|
|
|
|
public function all(): Collection;
|
|
|
|
|
2016-03-12 14:18:28 +01:00
|
|
|
/**
|
2016-04-26 08:09:10 +02:00
|
|
|
* Gives a user a role.
|
2016-03-12 14:18:28 +01:00
|
|
|
*/
|
|
|
|
public function attachRole(User $user, string $role): bool;
|
|
|
|
|
2017-09-26 08:52:16 +02:00
|
|
|
/**
|
2017-09-26 09:15:21 +02:00
|
|
|
* This updates the users email address and records some things so it can be confirmed or undone later.
|
|
|
|
* The user is blocked until the change is confirmed.
|
|
|
|
*
|
|
|
|
* @see updateEmail
|
2017-09-26 08:52:16 +02:00
|
|
|
*/
|
|
|
|
public function changeEmail(User $user, string $newEmail): bool;
|
|
|
|
|
2016-12-18 17:54:11 +01:00
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function changePassword(User $user, string $password);
|
|
|
|
|
2017-03-24 15:01:53 +01:00
|
|
|
public function changeStatus(User $user, bool $isBlocked, string $code): bool;
|
|
|
|
|
2016-03-12 14:18:28 +01:00
|
|
|
/**
|
2016-04-26 08:09:10 +02:00
|
|
|
* Returns a count of all users.
|
2016-03-12 14:18:28 +01:00
|
|
|
*/
|
|
|
|
public function count(): int;
|
2016-10-22 09:33:03 +02:00
|
|
|
|
2018-02-09 19:11:55 +01:00
|
|
|
public function createRole(string $name, string $displayName, string $description): Role;
|
|
|
|
|
2022-03-29 14:59:58 +02:00
|
|
|
public function deleteEmptyGroups(): void;
|
|
|
|
|
2023-03-09 06:33:23 +01:00
|
|
|
public function deleteInvite(InvitedUser $invite): void;
|
|
|
|
|
2016-12-12 15:24:47 +01:00
|
|
|
public function destroy(User $user): bool;
|
|
|
|
|
2021-09-18 10:26:12 +02:00
|
|
|
public function find(int $userId): ?User;
|
2018-03-30 16:44:33 +02:00
|
|
|
|
2021-09-18 10:26:12 +02:00
|
|
|
public function findByEmail(string $email): ?User;
|
2017-09-26 08:52:16 +02:00
|
|
|
|
2017-12-29 09:05:35 +01:00
|
|
|
/**
|
|
|
|
* Returns the first user in the DB. Generally only works when there is just one.
|
|
|
|
*/
|
|
|
|
public function first(): ?User;
|
|
|
|
|
2022-12-29 19:42:26 +01:00
|
|
|
public function getInvitedUsers(): Collection;
|
|
|
|
|
2018-02-09 19:11:55 +01:00
|
|
|
public function getRole(string $role): ?Role;
|
|
|
|
|
2019-02-12 21:49:28 +01:00
|
|
|
public function getRoleByUser(User $user): ?string;
|
|
|
|
|
2023-02-22 18:14:14 +01:00
|
|
|
public function getRolesInGroup(User $user, int $groupId): array;
|
|
|
|
|
2016-10-22 09:33:03 +02:00
|
|
|
/**
|
|
|
|
* Return basic user information.
|
|
|
|
*/
|
|
|
|
public function getUserData(User $user): array;
|
2017-03-19 17:54:21 +01:00
|
|
|
|
2023-12-20 19:35:52 +01:00
|
|
|
public function hasRole(null|Authenticatable|User $user, string $role): bool;
|
2017-09-26 09:15:21 +02:00
|
|
|
|
2023-12-20 19:35:52 +01:00
|
|
|
public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser;
|
2022-10-01 12:21:42 +02:00
|
|
|
|
|
|
|
public function redeemCode(string $code): void;
|
|
|
|
|
2019-08-22 17:06:43 +02:00
|
|
|
/**
|
|
|
|
* Remove any role the user has.
|
|
|
|
*/
|
2020-03-23 17:54:49 +01:00
|
|
|
public function removeRole(User $user, string $role): void;
|
2019-08-22 17:06:43 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set MFA code.
|
|
|
|
*/
|
|
|
|
public function setMFACode(User $user, ?string $code): void;
|
|
|
|
|
2017-12-29 09:05:35 +01:00
|
|
|
public function store(array $data): User;
|
|
|
|
|
2017-12-17 14:06:14 +01:00
|
|
|
public function unblockUser(User $user): void;
|
|
|
|
|
2018-03-03 08:12:18 +01:00
|
|
|
/**
|
|
|
|
* Update user info.
|
|
|
|
*/
|
|
|
|
public function update(User $user, array $data): User;
|
|
|
|
|
2017-09-26 09:15:21 +02:00
|
|
|
/**
|
2023-06-21 12:34:58 +02:00
|
|
|
* This updates the users email address. Same as changeEmail just without most logging. This makes sure that the
|
|
|
|
* undo/confirm routine can't catch this one. The user is NOT blocked.
|
2017-09-26 09:15:21 +02:00
|
|
|
*
|
|
|
|
* @see changeEmail
|
|
|
|
*/
|
|
|
|
public function updateEmail(User $user, string $newEmail): bool;
|
2022-12-29 19:42:26 +01:00
|
|
|
|
|
|
|
public function validateInviteCode(string $code): bool;
|
2016-03-14 20:38:23 +01:00
|
|
|
}
|