Do guarding controller
@param  string|null $loginRoute
@return $this
168796
public function guard($loginRoute = null)
    {
        $base = Base::instance();
        $currentPath = $base['PATH'];

        $this->parseFirewalls();

        if (
            $this->firewalls['pattern']
            && preg_match($this->firewalls['pattern'], $currentPath, $matches)
        ) {
            $key = static::pathName($matches['path']);
            $config = $this->firewalls['paths'][$key];

            if (!$this->isGranted($config['roles'])) {
                $base->reroute($loginRoute ?: $config['login_route']);
            }
        }

        return $this;
    }
229938
public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            $user = Auth::guard($guard)->user();
            $site = $user->site ?: site();
            $root = $site->getRootUrl();
            $userSlug = getSlug('userhome');

            $url = $root.'/'.$userSlug;
            return redirect()->away($url);
        }

        return $next($request);
    }
800740
public function ifGuest($guard = null)
    {
        $this->hideCallbacks->push(function () use ($guard) {
            return auth()->guard($guard)->user();
        });

        return $this;
    }
477366
public function handle(Login $request)
    {
        // Set up the auth data
        $userData = [
            'email'    => $request->get('email'),
            'password' => $request->get('password'),
        ];

        // Let the login service handle the checks.
        return $this->login
            ->loginUser($userData)
            ->redirectIntended();
    }
558016
public function setLoginData($loginId = null, $roleId = null, $unitId = null, \DateTime $logoutDate = null)
    {
        $this->loginData = [];

        return $this->updateLoginData($loginId, $roleId, $unitId, $logoutDate);
    }
631627
protected function setEditRoute($controller, $action): Controller
    {
        $callTo = Inflector::classify($controller) . '@' . $action;

        $this->routes['get'] = array_merge($this->routes['get'], [
            "/$controller/$action/{:id}/" => $callTo,
        ]);

        $this->routes['post'] = array_merge($this->routes['post'], [
            "/$controller/$action/" => $callTo,
        ]);
        
        $this->routes['post'] = array_merge($this->routes['post'], [
            "/$controller/$action/{:id}/" => $callTo,
        ]);

        return $this;
    }
827178
public function handle(Login $event)
    {
        $user = $event->user;
        $ip = $this->request->ip();
        $userAgent = $this->request->userAgent();
        $known = $user->authentications()->whereIpAddress($ip)->whereUserAgent($userAgent)->first();

        $authenticationLog = new AuthenticationLog([
            'ip_address' => $ip,
            'user_agent' => $userAgent,
            'login_at' => Carbon::now(),
        ]);

        $user->authentications()->save($authenticationLog);

        if (! $known && config('authentication-log.notify')) {
            $user->notify(new NewDevice($authenticationLog));
        }
    }
581494
public function handle($request, Closure $next, $guard = null)
    {
        if (Auth::guard($guard)->check()) {
            Talk::setAuthUserId(Auth::guard($guard)->user()->id);
        }

        return $next($request);
    }
499677
protected function callController($controller, $action, $route)
    {
        $controllers = $this->setting->getAsArray('auth.controller');
        $exclude = ($this->setting['auth.mode'] == 'exclude');
        $level = $this->setting->get('auth.level', 0);
        $inner = in_array($controller, $controllers);
        if ($exclude xor $inner) {
            if (!\Staq::Ctrl('Auth')->isLogged()) {
                throw new \Stack\Exception\MustBeLogged();
            }
            $user = \Staq::Ctrl('Auth')->currentUser();
            if ($user->hasAttribute('right')){
                if ($user->getAttribute('right')->getSeed() < $level) {
                    throw new \Stack\Exception\NotAllowed();
                }
            }
        }
        $result = parent::callController($controller, $action, $route);
        return $result;
    }
1179055
protected function initLoginRequired()
    {
        $routeInfo = Lb::app()->getRouteInfo();
        if (!in_array($routeInfo['controller'], Route::KERNEL_WEB_CTR) 
            || !in_array($routeInfo['action'], Route::KERNEL_WEB_ACTIONS)
        ) {
            $login_required_filter = Lb::app()->getLoginRequiredFilter();
            if (!isset($login_required_filter['controllers'][$routeInfo['controller']][$routeInfo['action']]) 
                || !$login_required_filter['controllers'][$routeInfo['controller']][$routeInfo['action']]
            ) {
                $login_default_url = Lb::app()->getLoginDefaultUrl();
                if (Lb::app()->isLoginRequired() && $login_default_url) {
                    Lb::app()->loginRequired($login_default_url);
                }
            }
        }
    }
418617
public function handle( $request, Closure $next, $guard = null )
	{
		return AccountManager::i()->guard( $guard )->basic() ?: $next( $request );
	}
777576
protected function enforceIsATraversable()
    {
        if ($this->isFlow()) {
            if ($this->isATraversable) {
                throw new NodalFlowException('Cannot Traverse a Branch');
            }

            return $this;
        }

        if ($this->isATraversable) {
            if (!($this instanceof TraversableNodeInterface)) {
                throw new NodalFlowException('Cannot Traverse a Node that does not implement TraversableNodeInterface');
            }

            return $this;
        }

        if (!($this instanceof ExecNodeInterface)) {
            throw new NodalFlowException('Cannot Exec a Node that does not implement ExecNodeInterface');
        }

        return $this;
    }
1021722
public function actionLogout($redirect = null)
	{
		\App::$domain->account->auth->logout();
		\App::$domain->navigation->alert->create(['account/auth', 'logout_success'], Alert::TYPE_SUCCESS);
		if($redirect) {
            return $this->redirect([SL . $redirect]);
        } else {
            return $this->goHome();
        }
	}
304161
public function postLogin(LoginRequest $request)
    {
        $inputs = $request->except('_token','rememberme');

        $rememberme = $request->get('rememberme');

        $attemp = Auth::attempt($inputs, !!$rememberme);

        if (!$attemp) {
            $request->session()->flash('error', trans('auth.failed'));
            return Redirect::back();
        }

        return Redirect::intended('/');

    }
1359047
public function bind($routeName)
    {
        if ($this->isFrozen) {
            throw new ControllerFrozenException(sprintf('Calling %s on frozen %s instance.', __METHOD__, __CLASS__));
        }

        $this->routeName = $routeName;

        return $this;
    }
317636
public function addUser(string $login_name, string $login_password, array $roles = []) : self
    {
        $this->users[$login_name]   = [
            'login_name'            => $login_name,
            'login_password'        => $login_password,
            'roles'                 => $roles,
        ];

        return $this;
    }
630124
public function setContentRoute(ContentRouteInterface $contentRoute)
    {
        $contentRoute->setClassType(get_class($this));
        $contentRoute->setLocale($this->page->getLocale());
        $contentRoute->setTemplateName($this->page->getTemplateName());
        $contentRoute->setName($this->page->getPageName());
        $this->contentRoute = $contentRoute;

        return $this;
    }