mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 00:04:24 +00:00
Implement user API and first tests.
This commit is contained in:
@@ -264,12 +264,12 @@ class UserRepository implements UserRepositoryInterface
|
||||
*/
|
||||
public function store(array $data): User
|
||||
{
|
||||
$password = bcrypt($data['password'] ?? app('str')->random(16));
|
||||
|
||||
return User::create(
|
||||
[
|
||||
'email' => $data['email'],
|
||||
'password' => $password,
|
||||
'blocked' => $data['blocked'] ?? false,
|
||||
'blocked_code' => $data['blocked_code'] ?? null,
|
||||
'email' => $data['email'],
|
||||
'password' => str_random(24),
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -286,6 +286,24 @@ class UserRepository implements UserRepositoryInterface
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user info.
|
||||
*
|
||||
* @param User $user
|
||||
* @param array $data
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function update(User $user, array $data): User
|
||||
{
|
||||
$this->updateEmail($user, $data['email']);
|
||||
$user->blocked = $data['blocked'] ?? false;
|
||||
$user->blocked_code = $data['blocked_code'] ?? null;
|
||||
$user->save();
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
@@ -31,7 +31,6 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
interface UserRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns a collection of all users.
|
||||
*
|
||||
@@ -159,6 +158,16 @@ interface UserRepositoryInterface
|
||||
*/
|
||||
public function unblockUser(User $user): void;
|
||||
|
||||
/**
|
||||
* Update user info.
|
||||
*
|
||||
* @param User $user
|
||||
* @param array $data
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function update(User $user, array $data): User;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
Reference in New Issue
Block a user