Skip to content

Question, authentication for asynchronous requests. #1068

Description

@aman1792

I encounter a problem with asynchronous requests.

I have set the token lifetime to 1 hour.
Module Version:

version = "7.x-2.16"
core = "7.x"
project = "restful"
datestamp = "1487139488"

Sometimes a Notice pops up when accessing a Resource.
Example:

\Drupal\test_api\Plugin\resource\TestResource__1_0::access
  public function access(): ?bool {
    $isAccess = parent::access();
    $isUserGrantAccess = user_access('api_create_test_content', $this->getAccount());

    if ($isAccess === FALSE || $isUserGrantAccess === FALSE) {
      throw new RestfulException(
        t(
          'You dont have access to the functionality. Contact your administrator.'
        ), 403
      );
    }

    return $isAccess && $isUserGrantAccess;
}

The $this->getAccount () method throws Notice: Trying to get property of non-object in the Drupal\restful_token_auth\Plugin\authentication\TokenAuthentication->authenticate()function

This is because
\Drupal\restful_token_auth\Plugin\authentication\TokenAuthentication
$auth_token = entity_load_single ('restful_token_auth', $id);
will return FALSE.

Additional information from the description:

entity_load_single
* @return
* The entity object, or FALSE.

You can check by putting after:

$auth_token = entity_load_single('restful_token_auth', $id);
$auth_token = FALSE;

@e0ipso What your think ?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions