dbmsv2/app/Services/Auth/LocalService.php
2025-08-26 13:55:36 +09:00

58 lines
1.2 KiB
PHP

<?php
namespace App\Services\Auth;
use App\Entities\UserEntity;
use App\Models\UserModel;
class LocalService extends AuthService
{
public function __construct()
{
parent::__construct(new UserModel());
$this->addClassName('Local');
}
public function getFormFields(): array
{
return [
'fields' => [
"id",
"passwd",
],
'filters' => [],
];
}
public function getIndexFields(): array
{
return [
'fields' => [
"id",
"passwd",
"status",
],
'filters' => [],
];
}
public function getBatchjobFields(): array
{
return ['status'];
}
public function getBatchjobButtons(): array
{
return [];
}
//기본기능
public function login(array $formDatas): UserEntity
{
$entity = $this->getEntity(['id' => $formDatas['id'], 'status' => UserEntity::DEFAULT_STATUS], false);
if (!$entity) {
throw new \Exception("{$formDatas['id']}에 대한 로그인 정보를 찾을수 없습니다.");
}
if (!password_verify($formDatas['passwd'], $entity->getPassword())) {
// log_message("error", "암호: {$formDatas['passwd']}, {$entity->passwd}");
throw new \Exception("암호가 맞지 않습니다.");
}
return $this->login_process($entity);
}
}