src/Phalcon/Auth/Middleware/Micro.php
protected function setEventChecker()
	{
		$diName = self::$diName;

		$eventsManager = $this->app->getEventsManager() ?? new EventsManager();
		$eventsManager->attach(
		    "micro:beforeExecuteRoute",
		    function (Event $event, $app) use($diName) {
		    	$auth = $app[$diName];

		    	// check if it has CORS support
		    	if ($auth->isIgnoreOptionsMethod() && $app['request']->getMethod() == 'OPTIONS') {
		    		return true;
		    	}

		        if($auth->isIgnoreUri()) {
		        	/**
		        	 * Let's try to parse if there's a token
		        	 * but we don't want to get an invalid token
		        	 */
		        	if( !$auth->check() && $this->getMessages()[0] != 'missing token') 
		        	{
		        		return $auth->unauthorized();
		        	}

		        	return true;
		        }

		        if($auth->check()) {
		        	return true;
		        }

		        return $auth->unauthorized();
		    }
		);

		$this->app->setEventsManager($eventsManager);
	}
protected function setEventChecker()
	{
		$diName = self::$diName;

		$eventsManager = $this->app->getEventsManager() ?? new EventsManager();
		$eventsManager->attach(
		    "micro:beforeExecuteRoute",
		    function (Event $event, $app) use($diName) {
		    	$auth = $app[$diName];

		    	// check if it has CORS support
		    	if ($auth->isIgnoreOptionsMethod() && $app['request']->getMethod() == 'OPTIONS') {
		    		return true;
		    	}

		        if($auth->isIgnoreUri()) {
		        	/**
		        	 * Let's try to parse if there's a token
		        	 * but we don't want to get an invalid token
		        	 */
		        	if( !$auth->check() && $this->getMessages()[0] != 'missing token') 
		        	{
		        		return $auth->unauthorized();
		        	}

		        	return true;
		        }

		        if($auth->check()) {
		        	return true;
		        }

		        return $auth->unauthorized();
		    }
		);

		$this->app->setEventsManager($eventsManager);
	}
protected function setEventChecker ( ) { $ diName = self :: $ diName ; $ eventsManager = $ this -> app -> getEventsManager ( ) ?? new EventsManager ( ) ; $ eventsManager -> attach ( "micro:beforeExecuteRoute" , function ( Event $ event , $ app ) use ( $ diName ) { $ auth = $ app [ $ diName ] ; // check if it has CORS support if ( $ auth -> isIgnoreOptionsMethod ( ) && $ app [ 'request' ] -> getMethod ( ) == 'OPTIONS' ) { return true ; } if ( $ auth -> isIgnoreUri ( ) ) { /**
		        	 * Let's try to parse if there's a token
		        	 * but we don't want to get an invalid token
		        	 */ if ( ! $ auth -> check ( ) && $ this -> getMessages ( ) [ 0 ] != 'missing token' ) { return $ auth -> unauthorized ( ) ; } return true ; } if ( $ auth -> check ( ) ) { return true ; } return $ auth -> unauthorized ( ) ; } ) ; $ this -> app -> setEventsManager ( $ eventsManager ) ; }
Sets event authentication.
Sets event authentication .