addClassPaths('Local'); } public function getFormService(): LocalForm { if ($this->_form === null) { $this->_form = new LocalForm(); $this->_form->setAttributes([ 'pk_field' => $this->model->getPKField(), 'title_field' => $this->model->getTitleField(), 'table' => $this->model->getTable(), 'useAutoIncrement' => $this->model->useAutoIncrement(), 'class_path' => $this->getClassPaths(false), ]); } return $this->_form; } public function action_init_process(string $action): void { parent::action_init_process($action); $fields = ['id', 'passwd']; $filters = []; switch ($action) { case 'login': case 'login_form': break; } $this->getFormService()->setFormFields($fields); $this->getFormService()->setFormRules($action, $fields); $this->getFormService()->setFormFilters($filters); $this->getFormService()->setFormOptions($filters); $this->getFormService()->setBatchjobFilters($filters); } protected function getEntity_process(mixed $entity): UserEntity { return $entity; } protected function login_process(array $formDatas): UserEntity { $entity = $this->getEntity(['id' => $formDatas['id'], 'status' => 'AVAILABLE'], true); if (!$entity instanceof UserEntity) { throw new \Exception("{$formDatas['id']}에 대한 로그인 정보를 찾을수 없습니다."); } if (!password_verify($formDatas['passwd'], $entity->getPassword())) { throw new \Exception("암호가 맞지 않습니다."); } return $entity; } public function login(AuthDTO $dto): UserEntity { if (!$dto instanceof LocalDTO) { throw new RuntimeException(__METHOD__ . "에서 오류발생: " . get_class($dto) . " DTO는 사용할 수 없습니다. LocalDTO만 허용됩니다."); } return parent::login($dto); } }