<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class verifiedAcount
{
    /**
     * Handle an incoming request.
     *
     * @param  \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response)  $next
     */
    public function handle(Request $request, Closure $next)
    {
        $user = auth()->user();
        if ($user && $user->is_active == 0) {
            auth()->logout();
            toast('Akun anda belum diaktivasi, silahkan hubungi admin', 'error')->position('top')->autoclose(5000);
            return redirect()->route('auth.login');
        }

        return $next($request);
    }
}
