33 lines
921 B
PHP
33 lines
921 B
PHP
<?php
|
|
|
|
namespace App\Services\Auth;
|
|
|
|
use App\Entities\UserEntity;
|
|
|
|
class LocalService extends AuthService
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function checkUser(array $formDatas): UserEntity
|
|
{
|
|
if (!isset($formDatas['id']) || !$formDatas['id']) {
|
|
throw new \Exception("사용자ID를 입력해주세요!");
|
|
}
|
|
if (!isset($formDatas['passwd']) || !$formDatas['passwd']) {
|
|
throw new \Exception("암호를 입력해주세요!");
|
|
}
|
|
$entity = $this->getModel()->getEntityByID($formDatas['id']);
|
|
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;
|
|
}
|
|
}
|