48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Auth;
|
|
|
|
use App\Entities\UserEntity as Entity;
|
|
use App\Models\UserModel as Model;
|
|
use CodeIgniter\HTTP\IncomingRequest;
|
|
|
|
class LocalService extends AuthService
|
|
{
|
|
public function __construct(?IncomingRequest $request = null)
|
|
{
|
|
parent::__construct($request);
|
|
}
|
|
final public function getClassName(): string
|
|
{
|
|
return "LocalAuth";
|
|
}
|
|
final public function getClassPath(): string
|
|
{
|
|
return $this->getClassName();
|
|
}
|
|
public function getModelClass(): string
|
|
{
|
|
return Model::class;
|
|
}
|
|
public function getEntityClass(): string
|
|
{
|
|
return Entity::class;
|
|
}
|
|
|
|
public function checkUser(array $formDatas): Entity
|
|
{
|
|
$this->getModel()->where("id", $formDatas['id']);
|
|
$entity = $this->getEntity();
|
|
if (is_null($entity) || !isset($entity->passwd)) {
|
|
throw new \Exception("사용자ID: {$formDatas['id']}가 존재하지 않습니다.");
|
|
}
|
|
|
|
if (!password_verify($formDatas['passwd'], $entity->passwd)) {
|
|
// log_message("error", "암호: {$formDatas['passwd']}, {$entity->passwd}");
|
|
throw new \Exception("암호가 맞지 않습니다.");
|
|
}
|
|
|
|
return $entity;
|
|
}
|
|
}
|