Sets up a new MFA device

@throws \Nails\Common\Exception\FactoryException
348877
protected function setupDevice()
    {
        $oSession   = Factory::service('Session', 'nails/module-auth');
        $oAuthModel = Factory::model('Auth', 'nails/module-auth');
        $oInput     = Factory::service('Input');

        if ($oInput->post()) {

            $oFormValidation = Factory::service('FormValidation');

            $oFormValidation->set_rules('mfa_secret', '', 'required');
            $oFormValidation->set_rules('mfa_code', '', 'required');

            $oFormValidation->set_message('required', lang('fv_required'));

            if ($oFormValidation->run()) {

                $sSecret  = $oInput->post('mfa_secret');
                $sMfaCode = $oInput->post('mfa_code');

                //  Verify the inout
                if ($oAuthModel->mfaDeviceSecretValidate($this->mfaUser->id, $sSecret, $sMfaCode)) {

                    //  Codes have been validated and saved to the DB, sign the user in and move on
                    $sStatus  = 'success';
                    $sMessage = '<strong>Multi Factor Authentication Enabled!</strong><br />You successfully ';
                    $sMessage .= 'associated an MFA device with your account. You will be required to use it ';
                    $sMessage .= 'the next time you log in.';

                    $oSession->setFlashData($sStatus, $sMessage);

                    $this->loginUser();

                } else {
                    $this->data['error'] = 'Sorry, that code failed to validate. Please try again.';
                }

            } else {
                $this->data['error'] = lang('fv_there_were_errors');
            }
        }

        //  Generate the secret
        $this->data['secret'] = $oAuthModel->mfaDeviceSecretGenerate(
            $this->mfaUser->id,
            $oInput->post('mfa_secret', true)
        );

        if (!$this->data['secret']) {

            $sStatus  = 'error';
            $sMessage = '<Strong>Sorry,</strong> it has not been possible to get an MFA device set up for this user. ';
            $sMessage .= $oAuthModel->lastError();

            $oSession->setFlashData($sStatus, $sMessage);

            if ($this->returnTo) {
                redirect('auth/login?return_to=' . $this->returnTo);
            } else {
                redirect('auth/login');
            }
        }

        // --------------------------------------------------------------------------

        $this->data['page']->title = 'Set up a new MFA device';
        $this->loadStyles(NAILS_APP_PATH . 'application/modules/auth/views/mfa/device/setup.php');
        Factory::service('View')
            ->load([
                'structure/header/blank',
                'auth/mfa/device/setup',
                'structure/footer/blank',
            ]);
    }
191562
private function setup()
    {
        self::$version = '3.1.7';
        self::$src = dirname(__FILE__);
        self::$dir = dirname(dirname(__FILE__));
        self::$url = $this->getCuztomUrl(self::$src);

        // Do
        do_action('cuztom_setup');
    }
338185
public void setMFADevices(java.util.Collection<MFADevice> mFADevices) {
        if (mFADevices == null) {
            this.mFADevices = null;
            return;
        }

        this.mFADevices = new com.amazonaws.internal.SdkInternalList<MFADevice>(mFADevices);
    }
1262955
public function setup(){
		if(($this->hasOption('autoinit') && $this->options()->autoinit) && ($this->hasOption('class') || $this->hasOption('default'))){
			$strClass = $this->hasOption('class') ? $this->options()->class : $this->options()->default;
			$this->setValue(new $strClass);
		}
	}
783649
protected function bootConfiguration(): void
    {
        $config = $this->app->make('config');
        $namespace = $this->hasPackageRepository() ? 'orchestra/html::' : 'orchestra.';

        $this->app->make('orchestra.form')->setConfig($config->get("{$namespace}form"));
        $this->app->make('orchestra.table')->setConfig($config->get("{$namespace}table"));
    }
245590
function setup() {
        $dataStore = new PersonalDataStoreStub();
        $this->eventStore = new TestEventStoreSpy();

        $this->container = new ContainerStub();
        $this->container->set(EventStore::class, $this->eventStore);

        $this->classMap  = new DomainEventClassMap();
        $this->commandBus = new ReflectionResolutionCommandBus($this->container);

        $this->serializer = new ReflectionBasedDomainEventSerializer(
            $this->classMap,
            new ValueSerializer($dataStore),
            $dataStore
        );
    }
1296171
public function setup()
    {
        $this->configure();
        $this->handleAppInclude();
        $this->validateConfiguration();
        $this->setupLogger();
        $this->setupRedis();
        $this->setupRedisEvents();
        $this->setupQueueStorage();
        $this->setupQueueFactory();
        $this->setupQueueRegistryAdapter();
        $this->setupQueueRegistry();
        $this->setupQueues();
        $this->setupFailureBackend();
        $this->setupStatisticBackend();
        $this->setupJobInstanceFactory();
        $this->setupWorkerFactory();
        $this->setupWorkerRegistryAdapter();
        $this->setupWorkerRegistry();
        $this->setupWorkers();
        $this->setupForeman();
    }
579468
protected function registerFactory()
    {
        $this->app->singleton(Factory::class, function ($app) {
            return new Factory($app[LoopInterface::class], $app[ConnectorInterface::class]);
        });
        $this->app->alias(Factory::class, 'ami.factory');
    }
223826
public function boot()
    {
        if ($this->app->runningInConsole()) {
            $this->publishes([
                __DIR__ . '/../config/config.php' => config_path('wallet.php'),
            ], 'config');

            $this->publishes([
                __DIR__ . '/../resources/migrations/' => database_path('migrations'),
            ], 'migrations');
        }
    }
1270190
protected function setup() {
		$conf = $this->conf;

		$dbh = $this->dbh = \mysqli_init();

		foreach ($this->conf['options'] as $key => $setting) {
			if ($setting != null && is_array($setting)) {
				mysqli_options($dbh, $setting['key'], $setting['value']);
			}
		}

		$this->preconnectConf($dbh);

		$this->establishConnection($dbh, $conf);

		$this->postconnectConf($dbh);

		/* check connection */
		if (mysqli_connect_errno()) {
			throw new Panic("Connect failed: " . \mysqli_connect_error());
		}

		\mysqli_set_charset($dbh, $conf['charset']);

		$offset = \hlin\Time::timezoneOffset($conf['timezone']);
		\mysqli_real_query($dbh, "SET time_zone='$offset';");
	}
511531
protected function _boot() {

			// Start the session
			session_start();

			// Create local inflector
			static::$inflector = Inflector::instance();

			// Create configuration
			$this->_configure();

			// Configure session :)
			session_set_cookie_params($this->config->sessionCookieExpireTime);
			if ($this->config->sessionRegenerateId) {
				session_regenerate_id();
			}
			
			// Apply Application's namespace
			AutoLoad::autoLoadNamespace($this->config->applicationNamespace, APP_PATH);

			// Auto load modules?
			if ($this->config->autoLoadModules == true) {
				$this->_loadModules();
			}

			// Create request
			$this->_request = new Request();
			
			// Check if static file exists?
			if ($this->config->staticThroughChickenWire && $this->_request->rawUri != '') {
			
				// In application?
				$filename = PUBLIC_PATH . $this->_request->rawUri;
				if (file_exists($filename)) {
					
					// Mime available?
					$mime = Mime::byFile($filename);
					
					// Send header
					Http::sendMimeType($mime);
					echo file_get_contents($filename);
					die;

				}

				// In modules
				foreach (Module::all() as $module) {

					// In this module?
					$regex = '/^' . preg_quote($module->urlPrefix, '/') . '\/(?<url>.+)$/';
					if (preg_match($regex, $this->_request->rawUri, $matches)) {

						// Does the file exist?
						$filename = $module->path . "/Public/" . $matches['url'];
						if (file_exists($filename)) {
							
							// Mime available?
							$mime = Mime::byFile($filename);
							
							// Send header
							Http::sendMimeType($mime);
							echo file_get_contents($filename);
							die;

						}

					} 

				}

			}

			// Try to route!
			$this->_matchRoute();

		}
122349
public function boot()
    {
        if (! $this->isRunningInBotManStudio()) {
            $this->loadDrivers();

            $this->publishes([
                __DIR__.'/../../stubs/telegram.php' => config_path('botman/telegram.php'),
            ]);

            $this->mergeConfigFrom(__DIR__.'/../../stubs/telegram.php', 'botman.telegram');

            $this->commands([
                TelegramRegisterCommand::class,
            ]);
        }
    }
389929
protected function bootstrapContainer()
    {
        static::setInstance($this);

        $this->instance('app', $this);
        $this->instance(self::class, $this);

        $this->instance('path', $this->path());
        $this->instance('path.base', $this->basePath());
        $this->instance('path.config', $this->basePath('resources/config'));
        $this->instance('path.database', $this->databasePath());
        $this->instance('path.storage', $this->storagePath());
        $this->instance('path.resources', $this->resourcePath());
        $this->instance('path.bootstrap', $this->bootstrapPath());

        $this->instance('env', $this->environment());

        $this->registerContainerAliases();
    }
1226756
protected function setup()
    {
        if (null === $this->getIdentity()) {
            throw new Exception\RuntimeException('A value for the identity was not provided');
        }

        if (null === $this->getCredential()) {
            throw new Exception\RuntimeException('A credential value was not provided');
        }

        $this->storeAuthenticationResult(AuthenticationResult::FAILURE_UNCATEGORIZED);
    }
530923
private function init()
    {
        $devicePatcher           = new Device\Xml\DevicePatcher();
        $deviceRepositoryBuilder = new Device\DeviceRepositoryBuilder(
            $this->getPersistenceStorage(),
            $this->getUserAgentHandlerChain(),
            $devicePatcher,
            $this->getLogger()
        );

        $this->deviceRepository = $deviceRepositoryBuilder->build(
            $this->getWurflConfig()->wurflFile,
            $this->getWurflConfig()->wurflPatches,
            $this->getWurflConfig()->capabilityFilter
        );
    }
798676
public static function setup(): void
    {
        $aComponents          = Components::available();
        self::$aContainers    = [];
        self::$aLoadedHelpers = [];
        $aDiscoveredServices  = [
            'nails/common' => self::findServicesForComponent('nails/common'),
        ];

        foreach ($aComponents as $oComponent) {
            $aDiscoveredServices[$oComponent->slug] = self::findServicesForComponent($oComponent->slug);
        }

        $aDiscoveredServices['app'] = self::findServicesForApp();
        $aDiscoveredServices        = array_filter($aDiscoveredServices);

        foreach ($aDiscoveredServices as $sComponentName => $aComponentServices) {

            //  Properties
            if (!empty($aComponentServices['properties'])) {
                if (empty(self::$aContainers[$sComponentName]['properties'])) {
                    self::$aContainers[$sComponentName]['properties'] = new Container();
                }
                foreach ($aComponentServices['properties'] as $sKey => $mValue) {
                    self::$aContainers[$sComponentName]['properties'][$sKey] = $mValue;
                }
            }

            // --------------------------------------------------------------------------

            /**
             * SERVICES
             * All services are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['services'])) {
                if (empty(self::$aContainers[$sComponentName]['services'])) {
                    self::$aContainers[$sComponentName]['services'] = new Container();
                }
                foreach ($aComponentServices['services'] as $sKey => $cCallable) {
                    self::$aContainers[$sComponentName]['services'][$sKey] = function () use ($sKey, $cCallable) {
                        return $cCallable;
                    };;
                }
            }

            // --------------------------------------------------------------------------

            /**
             * MODELS
             * All models are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['models'])) {
                if (empty(self::$aContainers[$sComponentName]['models'])) {
                    self::$aContainers[$sComponentName]['models'] = new Container();
                }
                foreach ($aComponentServices['models'] as $sKey => $cCallable) {
                    self::$aContainers[$sComponentName]['models'][$sKey] = function () use ($cCallable) {
                        return $cCallable;
                    };
                }
            }

            // --------------------------------------------------------------------------

            /**
             * FACTORIES
             * All factories are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['factories'])) {
                if (empty(self::$aContainers[$sComponentName]['factories'])) {
                    self::$aContainers[$sComponentName]['factories'] = new Container();
                }
                foreach ($aComponentServices['factories'] as $sKey => $cCallable) {

                    $cWrapper = function () use ($cCallable) {
                        return $cCallable;
                    };

                    self::$aContainers[$sComponentName]['factories'][$sKey] = self::$aContainers[$sComponentName]['factories']
                        ->factory($cWrapper);
                }
            }

            // --------------------------------------------------------------------------

            /**
             * FACTORIES
             * All factories are wrapped in a closure, this is so that on fetch we can
             * pass in any additional arguments as parameters which can be used in the
             * item's constructor
             */
            if (!empty($aComponentServices['resources'])) {
                if (empty(self::$aContainers[$sComponentName]['resources'])) {
                    self::$aContainers[$sComponentName]['resources'] = new Container();
                }
                foreach ($aComponentServices['resources'] as $sKey => $cCallable) {

                    $cWrapper = function () use ($cCallable) {
                        return $cCallable;
                    };

                    self::$aContainers[$sComponentName]['resources'][$sKey] = self::$aContainers[$sComponentName]['resources']
                        ->factory($cWrapper);
                }
            }
        }
    }
1002512
public static function boot() : void
    {
        $container = self::getContainer();
        $container->singleton('app', $container);

        Facade::setFacadeApplication($container);
    }