original_string: public function postTwoFactor()
      {
          // Check that we have a session.
          if ($userId = Session::pull('2fa_id')) {
              $code = str_replace(' ', '', Binput::get('code'));
  
              // Maybe a temp login here.
              Auth::loginUsingId($userId);
  
              $user = Auth::user();
  
              $valid = Google2FA::verifyKey($user->google_2fa_secret, $code);
  
              if ($valid) {
                  event(new UserPassedTwoAuthEvent($user));
  
                  event(new UserLoggedInEvent($user));
  
                  return Redirect::intended('dashboard');
              } else {
                  event(new UserFailedTwoAuthEvent($user));
  
                  // Failed login, log back out.
                  Auth::logout();
  
                  return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token'));
              }
          }
  
          return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token'));
      }
code: public function postTwoFactor()
      {
          // Check that we have a session.
          if ($userId = Session::pull('2fa_id')) {
              $code = str_replace(' ', '', Binput::get('code'));
  
              // Maybe a temp login here.
              Auth::loginUsingId($userId);
  
              $user = Auth::user();
  
              $valid = Google2FA::verifyKey($user->google_2fa_secret, $code);
  
              if ($valid) {
                  event(new UserPassedTwoAuthEvent($user));
  
                  event(new UserLoggedInEvent($user));
  
                  return Redirect::intended('dashboard');
              } else {
                  event(new UserFailedTwoAuthEvent($user));
  
                  // Failed login, log back out.
                  Auth::logout();
  
                  return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token'));
              }
          }
  
          return cachet_redirect('auth.login')->withError(trans('forms.login.invalid-token'));
      }
code_tokens: public function postTwoFactor ( ) { // Check that we have a session. if ( $ userId = Session :: pull ( '2fa_id' ) ) { $ code = str_replace ( ' ' , '' , Binput :: get ( 'code' ) ) ; // Maybe a temp login here. Auth :: loginUsingId ( $ userId ) ; $ user = Auth :: user ( ) ; $ valid = Google2FA :: verifyKey ( $ user -> google_2fa_secret , $ code ) ; if ( $ valid ) { event ( new UserPassedTwoAuthEvent ( $ user ) ) ; event ( new UserLoggedInEvent ( $ user ) ) ; return Redirect :: intended ( 'dashboard' ) ; } else { event ( new UserFailedTwoAuthEvent ( $ user ) ) ; // Failed login, log back out. Auth :: logout ( ) ; return cachet_redirect ( 'auth.login' ) -> withError ( trans ( 'forms.login.invalid-token' ) ) ; } } return cachet_redirect ( 'auth.login' ) -> withError ( trans ( 'forms.login.invalid-token' ) ) ; }
docstring: Validates the Two Factor token.
  
  This feels very hacky, but we have to juggle authentication and codes.
  
  @return \Illuminate\Http\RedirectResponse
docstring_tokens: Validates the Two Factor token .