36 lines
926 B
PHP
36 lines
926 B
PHP
<?php
|
|
|
|
namespace App\Libraries\Adapter\Auth;
|
|
|
|
use App\Entities\UserEntity;
|
|
|
|
class LocalAdapter extends Adapter
|
|
{
|
|
public function __construct(string $site, $debug = false)
|
|
{
|
|
parent::__construct($site, $debug);
|
|
}
|
|
public function getAuthButton()
|
|
{
|
|
return "";
|
|
}
|
|
|
|
public function signin(array $formDatas): UserEntity
|
|
{
|
|
if (!isset($formDatas['id']) || !$formDatas['id'] || !isset($formDatas['passwd']) || !$formDatas['passwd']) {
|
|
throw new \Exception("ID 나 암호의 값이 없습니다.");
|
|
}
|
|
|
|
$entity = $this->getUserModel()->getEntityByField('id', $formDatas['id']);
|
|
if (is_null($entity)) {
|
|
throw new \Exception("사용자ID: {$formDatas['id']}가 존재하지 않습니다.");
|
|
}
|
|
if (!password_verify($formDatas['passwd'], $entity->passwd)) {
|
|
throw new \Exception("암호가 맞지않습니다.");
|
|
}
|
|
//Session에 인증정보 설정
|
|
$this->setUserSession($entity);
|
|
return $entity;
|
|
}
|
|
}
|