Automation init...2
This commit is contained in:
parent
1973a55bfb
commit
0bd684e8fe
@ -41,7 +41,7 @@ abstract class BaseController extends Controller
|
|||||||
* Be sure to declare properties for any property fetch you initialized.
|
* Be sure to declare properties for any property fetch you initialized.
|
||||||
* The creation of dynamic property is deprecated in PHP 8.2.
|
* The creation of dynamic property is deprecated in PHP 8.2.
|
||||||
*/
|
*/
|
||||||
// protected $session;
|
protected $session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
|
|||||||
@ -3,16 +3,23 @@
|
|||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Controllers\BaseController;
|
use App\Controllers\BaseController;
|
||||||
use App\Trait\AuthTrait;
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
|
use CodeIgniter\HTTP\ResponseInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
use App\Traits\AuthTrait;
|
||||||
|
|
||||||
abstract class CommonController extends BaseController
|
abstract class CommonController extends BaseController
|
||||||
{
|
{
|
||||||
use AuthTrait;
|
use AuthTrait;
|
||||||
private $_datas = [];
|
private $_datas = [];
|
||||||
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||||
protected function __construct()
|
|
||||||
{
|
{
|
||||||
$this->_datas['session'] = $this->login_check();
|
// Do Not Edit This Line
|
||||||
|
parent::initController($request, $response, $logger);
|
||||||
|
// Preload any models, libraries, etc, here.
|
||||||
|
// E.g.: $this->session = \Config\Services::session();
|
||||||
|
$this->session = $this->login_check();
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function __get($name): array|null
|
final public function __get($name): array|null
|
||||||
|
|||||||
@ -1,16 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Trait;
|
namespace App\Traits;
|
||||||
|
|
||||||
trait AuthTrait
|
trait AuthTrait
|
||||||
{
|
{
|
||||||
public function login_check(): array
|
public function login_check(): array
|
||||||
{
|
{
|
||||||
//사용자 기본 Role 지정
|
//사용자 기본 Role 지정
|
||||||
$session = [];
|
|
||||||
$session[SESSION['NAMES']['ISLOGIN']] = false;
|
$session[SESSION['NAMES']['ISLOGIN']] = false;
|
||||||
$session['currentRoles'] = [DEFAULTS["ROLE"]];
|
$session['currentRoles'] = [DEFAULTS["ROLE"]];
|
||||||
if ($this->_session->get(SESSION['NAMES']['ISLOGIN'])) {
|
if (\Config\Services::session()->get(SESSION['NAMES']['ISLOGIN'])) {
|
||||||
$session[SESSION['NAMES']['ISLOGIN']] = true;
|
$session[SESSION['NAMES']['ISLOGIN']] = true;
|
||||||
$session['auth'] = $this->_session->get(SESSION['NAMES']['AUTH']);
|
$session['auth'] = $this->_session->get(SESSION['NAMES']['AUTH']);
|
||||||
$currentRoles = explode(DEFAULTS['DELIMITER_ROLE'], $session['auth'][AUTH['FIELDS']['ROLE']]);
|
$currentRoles = explode(DEFAULTS['DELIMITER_ROLE'], $session['auth'][AUTH['FIELDS']['ROLE']]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user