<?php

namespace App\Traits;

trait AuthTrait
{
    final protected function loginCheck_AuthTrait(): array
    {
        //사용자 기본 Role 지정
        $session[SESSION_NAMES['ISLOGIN']] = false;
        $session['currentRoles'] = [DEFAULTS["ROLE"]];
        if (\Config\Services::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;
    }
}
