<?php

declare(strict_types=1);

namespace App\Listeners;
use Illuminate\Auth\Events\Authenticated;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Auth;

class LogAuthenticated
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  \Illuminate\Auth\Events\Authenticated  $event
     * @return void
     */
    public function handle(Authenticated $event)
    {
        $user = $event->user;

        uopz_redefine('UID', $user->id); // 회원번호
        uopz_redefine('SID', $user->sid); // 회원ID
        uopz_redefine('IS_USER', intval(Auth::check())); // 일반회원
        uopz_redefine('IS_ADMIN', intval($user->is_admin)); // 관리자

        // 회원 정보 공유
        View::share('user', $user);
    }
}
