37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Auth;
|
|
|
|
use App\Entities\UserEntity;
|
|
use App\Services\Auth\LocalService;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
/**
|
|
* @property LocalService $service
|
|
* IDE에게 protected $service 속성이 LocalService 타입임을 알려줍니다.
|
|
*/
|
|
class LocalController extends AuthController
|
|
{
|
|
public const PATH = 'login';
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
if ($this->service === null) {
|
|
$this->service = service('localauth');
|
|
}
|
|
$this->addActionPaths(self::PATH);
|
|
}
|
|
//로그인처리
|
|
protected function login_process(): UserEntity
|
|
{
|
|
$formDatas = $this->doValidation(__FUNCTION__);
|
|
return $this->service->login($formDatas);
|
|
}
|
|
protected function logout_process(): void
|
|
{
|
|
$this->service->logout();
|
|
}
|
|
}
|