mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06: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.
|
||||
|
||||
Reference in New Issue
Block a user