public function post2faRegisterDisplayForm(Request $request) {

        if (config('lasallecmsusermanagement.auth_users_registration_front_end_require_terms_of_service')) {
            if (!$request->input('terms-of-service')) {
                return redirect()->route('auth.register')
                    ->withInput($request->only('name', 'email', 'phone_country_code', 'phone_number'))
                    ->withErrors([
                        'terms-of-service' => 'Please read our Terms of Service',
                    ]);
            }
        }

        // Go through the special validation-only command bus
        $response = $this->dispatchFrom(Create2faRegisterUserCommand::class, $request);

        //Session::flash('status_code', $response['status_code'] );

        if ($response['status_text'] == "validation_failed") {
            Session::flash('message', $response['errorMessages']->first());
            // Return to the edit form with error messages
            return Redirect::back()
                ->withInput($response['data'])
                ->withErrors($response['errorMessages']);
        }


        // The validation is ok. Now, onto the Two Factor Authorization.
        $this->twoFactorAuthHelper->doTwoFactorAuthRegistration($response['data']);


        // The initial validation is ok, but we do not want to set up an actual database record until the 2FA
        // is complete. Otherwise, the bots could create actual records, which is something we are trying to avoid
        // with the 2FA process.

        // The 2FA code session var is set in $this->twoFactorAuthHelper->doTwoFactorAuthRegistration($response['data']);

        return view('usermanagement::frontend.' . $this->frontend_template_name . '.register.two_factor_auth', [
            'title'                    => 'Register',
            'two_factor_auth_workflow' => true,
            'name'                     => $response['data']['name'],
            'email'                    => $response['data']['email'],
            'password'                 => $response['data']['password'],
            'password_confirmation'    => $response['data']['password_confirmation'],
            'phone_country_code'       => $response['data']['phone_country_code'],
            'phone_number'             => $response['data']['phone_number'],
            'formStartDateTime'        => Carbon::now(),
        ]);
    }
public function post2faRegisterDisplayForm(Request $request) {

        if (config('lasallecmsusermanagement.auth_users_registration_front_end_require_terms_of_service')) {
            if (!$request->input('terms-of-service')) {
                return redirect()->route('auth.register')
                    ->withInput($request->only('name', 'email', 'phone_country_code', 'phone_number'))
                    ->withErrors([
                        'terms-of-service' => 'Please read our Terms of Service',
                    ]);
            }
        }

        // Go through the special validation-only command bus
        $response = $this->dispatchFrom(Create2faRegisterUserCommand::class, $request);

        //Session::flash('status_code', $response['status_code'] );

        if ($response['status_text'] == "validation_failed") {
            Session::flash('message', $response['errorMessages']->first());
            // Return to the edit form with error messages
            return Redirect::back()
                ->withInput($response['data'])
                ->withErrors($response['errorMessages']);
        }


        // The validation is ok. Now, onto the Two Factor Authorization.
        $this->twoFactorAuthHelper->doTwoFactorAuthRegistration($response['data']);


        // The initial validation is ok, but we do not want to set up an actual database record until the 2FA
        // is complete. Otherwise, the bots could create actual records, which is something we are trying to avoid
        // with the 2FA process.

        // The 2FA code session var is set in $this->twoFactorAuthHelper->doTwoFactorAuthRegistration($response['data']);

        return view('usermanagement::frontend.' . $this->frontend_template_name . '.register.two_factor_auth', [
            'title'                    => 'Register',
            'two_factor_auth_workflow' => true,
            'name'                     => $response['data']['name'],
            'email'                    => $response['data']['email'],
            'password'                 => $response['data']['password'],
            'password_confirmation'    => $response['data']['password_confirmation'],
            'phone_country_code'       => $response['data']['phone_country_code'],
            'phone_number'             => $response['data']['phone_number'],
            'formStartDateTime'        => Carbon::now(),
        ]);
    }
public function post2faRegisterDisplayForm ( Request $ request ) { if ( config ( 'lasallecmsusermanagement.auth_users_registration_front_end_require_terms_of_service' ) ) { if ( ! $ request -> input ( 'terms-of-service' ) ) { return redirect ( ) -> route ( 'auth.register' ) -> withInput ( $ request -> only ( 'name' , 'email' , 'phone_country_code' , 'phone_number' ) ) -> withErrors ( [ 'terms-of-service' => 'Please read our Terms of Service' , ] ) ; } } // Go through the special validation-only command bus $ response = $ this -> dispatchFrom ( Create2faRegisterUserCommand :: class , $ request ) ; //Session::flash('status_code', $response['status_code'] ); if ( $ response [ 'status_text' ] == "validation_failed" ) { Session :: flash ( 'message' , $ response [ 'errorMessages' ] -> first ( ) ) ; // Return to the edit form with error messages return Redirect :: back ( ) -> withInput ( $ response [ 'data' ] ) -> withErrors ( $ response [ 'errorMessages' ] ) ; } // The validation is ok. Now, onto the Two Factor Authorization. $ this -> twoFactorAuthHelper -> doTwoFactorAuthRegistration ( $ response [ 'data' ] ) ; // The initial validation is ok, but we do not want to set up an actual database record until the 2FA // is complete. Otherwise, the bots could create actual records, which is something we are trying to avoid // with the 2FA process. // The 2FA code session var is set in $this->twoFactorAuthHelper->doTwoFactorAuthRegistration($response['data']); return view ( 'usermanagement::frontend.' . $ this -> frontend_template_name . '.register.two_factor_auth' , [ 'title' => 'Register' , 'two_factor_auth_workflow' => true , 'name' => $ response [ 'data' ] [ 'name' ] , 'email' => $ response [ 'data' ] [ 'email' ] , 'password' => $ response [ 'data' ] [ 'password' ] , 'password_confirmation' => $ response [ 'data' ] [ 'password_confirmation' ] , 'phone_country_code' => $ response [ 'data' ] [ 'phone_country_code' ] , 'phone_number' => $ response [ 'data' ] [ 'phone_number' ] , 'formStartDateTime' => Carbon :: now ( ) , ] ) ; }
The front-end 2FA registration form comes here.

This method validates the form data only. This validation occurs via the command bus as usual; however,
I modified the command bus flow to accommodate this special validation-only. So far (v1.01), this is the
one-and-only time where any changes to the command bus are happening. It's happening here because all the
validation goodness needs to happen, but there is one extra step to interject before the persist. When this
second 2FA is successful, the original command bus, that is used for the regular non-2FA front-end user
registration, is used in all its original glory. Meaning, the entire validation happens again. The assumption
is that the sanitation and validation will always process flawlessly the second time around.

@param  \Illuminate\Http\Request  $request
@return \Illuminate\Http\Response
The front - end 2FA registration form comes here .