protected function requestCode()
    {
        $oInput = Factory::service('Input');
        if ($oInput->post()) {

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

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

            if ($oFormValidation->run()) {

                $oAuthModel = Factory::model('Auth', 'nails/module-auth');
                $sMfaCode   = $oInput->post('mfa_code');

                //  Verify the inout
                if ($oAuthModel->mfaDeviceCodeValidate($this->mfaUser->id, $sMfaCode)) {
                    $this->loginUser();
                } else {
                    $this->data['error'] = 'Sorry, that code failed to validate. Please try again. ';
                    $this->data['error'] .= $oAuthModel->lastError();
                }

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

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

        $this->data['page']->title = 'Enter your Code';
        $this->loadStyles(NAILS_APP_PATH . 'application/modules/auth/views/mfa/device/ask.php');
        Factory::service('View')
            ->load([
                'structure/header/blank',
                'auth/mfa/device/ask',
                'structure/footer/blank',
            ]);
    }
protected function requestCode()
    {
        $oInput = Factory::service('Input');
        if ($oInput->post()) {

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

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

            if ($oFormValidation->run()) {

                $oAuthModel = Factory::model('Auth', 'nails/module-auth');
                $sMfaCode   = $oInput->post('mfa_code');

                //  Verify the inout
                if ($oAuthModel->mfaDeviceCodeValidate($this->mfaUser->id, $sMfaCode)) {
                    $this->loginUser();
                } else {
                    $this->data['error'] = 'Sorry, that code failed to validate. Please try again. ';
                    $this->data['error'] .= $oAuthModel->lastError();
                }

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

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

        $this->data['page']->title = 'Enter your Code';
        $this->loadStyles(NAILS_APP_PATH . 'application/modules/auth/views/mfa/device/ask.php');
        Factory::service('View')
            ->load([
                'structure/header/blank',
                'auth/mfa/device/ask',
                'structure/footer/blank',
            ]);
    }
protected function requestCode ( ) { $ oInput = Factory :: service ( 'Input' ) ; if ( $ oInput -> post ( ) ) { $ oFormValidation = Factory :: service ( 'FormValidation' ) ; $ oFormValidation -> set_rules ( 'mfa_code' , '' , 'required' ) ; $ oFormValidation -> set_message ( 'required' , lang ( 'fv_required' ) ) ; if ( $ oFormValidation -> run ( ) ) { $ oAuthModel = Factory :: model ( 'Auth' , 'nails/module-auth' ) ; $ sMfaCode = $ oInput -> post ( 'mfa_code' ) ; //  Verify the inout if ( $ oAuthModel -> mfaDeviceCodeValidate ( $ this -> mfaUser -> id , $ sMfaCode ) ) { $ this -> loginUser ( ) ; } else { $ this -> data [ 'error' ] = 'Sorry, that code failed to validate. Please try again. ' ; $ this -> data [ 'error' ] .= $ oAuthModel -> lastError ( ) ; } } else { $ this -> data [ 'error' ] = lang ( 'fv_there_were_errors' ) ; } } // -------------------------------------------------------------------------- $ this -> data [ 'page' ] -> title = 'Enter your Code' ; $ this -> loadStyles ( NAILS_APP_PATH . 'application/modules/auth/views/mfa/device/ask.php' ) ; Factory :: service ( 'View' ) -> load ( [ 'structure/header/blank' , 'auth/mfa/device/ask' , 'structure/footer/blank' , ] ) ; }
Requests a code from the user

@throws \Nails\Common\Exception\FactoryException
Requests a code from the user