51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Auth;
|
|
|
|
use App\Entities\UserEntity;
|
|
use App\Models\UserModel;
|
|
use CodeIgniter\HTTP\IncomingRequest;
|
|
|
|
class LocalService extends AuthService
|
|
{
|
|
public function __construct(?IncomingRequest $request = null)
|
|
{
|
|
parent::__construct($request);
|
|
$this->addClassName('Local');
|
|
}
|
|
final public function getModelClass(): UserModel
|
|
{
|
|
return new UserModel();
|
|
}
|
|
final public function getEntityClass(): UserEntity
|
|
{
|
|
return new UserEntity();
|
|
}
|
|
|
|
public function getFormFields(): array
|
|
{
|
|
return [
|
|
"id",
|
|
"passwd",
|
|
];
|
|
}
|
|
public function getFilterFields(): array
|
|
{
|
|
return [];
|
|
}
|
|
public function getBatchJobFields(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function login(array $formDatas): UserEntity
|
|
{
|
|
$entity = $this->getEntity(['id' => $formDatas['id'], 'status' => DEFAULTS['STATUS']]);
|
|
if (!password_verify($formDatas['passwd'], $entity->getPassword())) {
|
|
// log_message("error", "암호: {$formDatas['passwd']}, {$entity->passwd}");
|
|
throw new \Exception("암호가 맞지 않습니다.");
|
|
}
|
|
return $this->login_process($entity);
|
|
}
|
|
}
|