public function testGettingUserWhenAlreadyAuthenticatedReturnsUser()
 {
     $auth = new Authenticator($this->router, $this->container, ['provider' => Mockery::mock('Dingo\\Api\\Auth\\Provider')]);
     $auth->setUser((object) ['id' => 1]);
     $this->assertEquals(1, $auth->user()->id);
     $this->assertTrue($auth->check());
 }
Beispiel #2
0
 /**
  * Peform authentication before a request is executed.
  *
  * @param \Dingo\Api\Routing\Route $route
  * @param \Illuminate\Http\Request $request
  * @param dynamic                  $provider
  *
  * @return mixed
  */
 public function filter(Route $route, Request $request)
 {
     if ($this->routeNotProtected($route) || $this->userIsLogged()) {
         return;
     }
     $providers = array_merge(array_slice(func_get_args(), 2), $route->getAuthProviders());
     $this->auth->authenticate($providers);
 }
Beispiel #3
0
 /**
  * Refresh the request stack.
  *
  * This is done by resetting the authentication, popping
  * the last request from the stack, replacing the input,
  * and resetting the version and parameters.
  *
  * @return void
  */
 protected function refreshRequestStack()
 {
     if (!$this->persistAuthentication) {
         $this->auth->setUser(null);
         $this->persistAuthentication = true;
     }
     if ($route = array_pop($this->routeStack)) {
         $this->router->setCurrentRoute($route);
     }
     $this->replaceRequestInstance();
     $this->clearCachedFacadeInstance();
     $this->raw = false;
     $this->version = $this->domain = $this->content = null;
     $this->parameters = $this->uploads = [];
 }