cfmgrv4/app/Libraries/MyAuth/MyAuth.php
2024-10-05 23:56:06 +09:00

49 lines
1.1 KiB
PHP

<?php
namespace App\Libraries\MyAuth;
use App\Entities\UserEntity;
use App\Models\UserModel;
use App\Models\SNSUserModel;
// 참고:https://github.com/SyntaxPhoenix/iloclient
abstract class MyAuth
{
private $_userModel = null;
private $_snsUserModel = null;
protected $_session = null;
protected function __construct()
{
$this->_session = \Config\Services::session();
}
abstract public function getAuthButton();
abstract public function execute(): UserEntity;
final protected function getUserModel(): UserModel
{
if (is_null($this->_userModel)) {
$this->_userModel = new UserModel();
}
return $this->_userModel;
}
final protected function getUserSNSModel(): SNSUSerModel
{
if (is_null($this->_snsUserModel)) {
$this->_snsUserModel = new SNSUserModel();
}
return $this->_snsUserModel;
}
protected function setSession_process(UserEntity $entity): UserEntity
{
$this->_session->set(SESSION_NAMES['ISLOGIN'], true);
$this->_session->set(SESSION_NAMES['AUTH'], [
'uid' => $entity->getPK(),
'name' => $entity->getTitle(),
'role' => $entity->role
]);
return $entity;
}
}