Implement user API and first tests.

This commit is contained in:
James Cole
2018-03-03 08:12:18 +01:00
parent 60339a0f6a
commit 9475fef8f6
13 changed files with 505 additions and 58 deletions

View File

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