34 lines
731 B
PHP
Executable File
34 lines
731 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\LoginRequest;
|
|
use App\Http\Requests\RegisterRequest;
|
|
use App\Services\UserService;
|
|
|
|
class PublicUserController extends Controller
|
|
{
|
|
public function __construct(
|
|
private UserService $userService
|
|
) {
|
|
}
|
|
|
|
public function register(RegisterRequest $request)
|
|
{
|
|
$this->userService->create($request->all());
|
|
}
|
|
|
|
public function login(LoginRequest $request)
|
|
{
|
|
if (!$this->userService->login($request->all())) {
|
|
return response()
|
|
->json('bad_password', 400);
|
|
}
|
|
}
|
|
|
|
public function reset(LoginRequest $request)
|
|
{
|
|
$this->userService->setPassword($request->all());
|
|
}
|
|
}
|