<?php

namespace addons\csmtable\library\xcore\xcore\base;

use think\Config;
use think\Session;
use app\admin\library\Auth;
use addons\csmtable\library\xcore\xcore\utils\XcDaoUtils;

class XcAdminAuth extends Auth
{
    /**
     * @return XcAdminAuth
     */
    public static function instance($options = [])
    {
        if (is_null(self::$instance)) {
            self::$instance = new static($options);
        }

        return self::$instance;
    }

    public function directLogin($adminId)
    {
        Config::set('fastadmin.loginip_check', false);
        if (!$this->isLogin()) {
            $admin = XcDaoUtils::getRowById(new \app\admin\model\Admin(), $adminId);
            Session::set("admin", $admin->toArray());
            Session::set("admin.safecode", $this->getEncryptSafecode($admin));
        }
    }
}
