mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Improve testing of middleware.
This commit is contained in:
@@ -168,6 +168,16 @@ class UserRepository implements UserRepositoryInterface
|
||||
return User::where('email', $email)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first user in the DB. Generally only works when there is just one.
|
||||
*
|
||||
* @return null|User
|
||||
*/
|
||||
public function first(): ?User
|
||||
{
|
||||
return User::first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return basic user information.
|
||||
*
|
||||
@@ -225,6 +235,23 @@ class UserRepository implements UserRepositoryInterface
|
||||
return $user->hasRole($role);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function store(array $data): User
|
||||
{
|
||||
$password = bcrypt($data['password'] ?? app('str')->random(16));
|
||||
|
||||
return User::create(
|
||||
[
|
||||
'email' => $data['email'],
|
||||
'password' => $password,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
|
@@ -37,6 +37,20 @@ interface UserRepositoryInterface
|
||||
*/
|
||||
public function all(): Collection;
|
||||
|
||||
/**
|
||||
* Returns the first user in the DB. Generally only works when there is just one.
|
||||
*
|
||||
* @return null|User
|
||||
*/
|
||||
public function first(): ?User;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function store(array $data): User;
|
||||
|
||||
/**
|
||||
* Gives a user a role.
|
||||
*
|
||||
|
Reference in New Issue
Block a user