Automation/app/Traits/AuthTrait.php
2024-09-09 11:22:23 +09:00

22 lines
719 B
PHP

<?php
namespace App\Trait;
trait AuthTrait
{
public function login_check(): array
{
//사용자 기본 Role 지정
$session = [];
$session[SESSION['NAMES']['ISLOGIN']] = false;
$session['currentRoles'] = [DEFAULTS["ROLE"]];
if ($this->_session->get(SESSION['NAMES']['ISLOGIN'])) {
$session[SESSION['NAMES']['ISLOGIN']] = true;
$session['auth'] = $this->_session->get(SESSION['NAMES']['AUTH']);
$currentRoles = explode(DEFAULTS['DELIMITER_ROLE'], $session['auth'][AUTH['FIELDS']['ROLE']]);
$session['currentRoles'] = is_array($currentRoles) ? $currentRoles : [DEFAULTS["ROLE"]];
}
return $session;
}
}