<?php

namespace App\Http\Middleware;

use Closure;

class ChannelAuth
{
    /**
     * 判断是否登陆.
     */
    public function handle($request, Closure $next)
    {
        $current_url = url()->current();

        //判断如果是登陆、注册
        if(strpos($current_url,'passport/login') || strpos($current_url,'passport/register'))
        {
             if(session('ydyauth')) return redirect()->secure('/');
        }else{
            if(!session('ydyauth')) return redirect()->secure('/passport/login');
        }

        $response = $next($request);
        return $response;
    }
}
