This route can only be accessed by anonymous users

Created on 16 June 2022, almost 3 years ago
Updated 7 December 2023, over 1 year ago

I am trying to register a user via jsonAPI but when I do I get error 403: Access Denied - This route can only be accessed by anonymous users

Here's the data:

Headers:
Content-Type:application/json
method: post
URL: /jsonapi/user/register
body:
{
"name":[{"value":"name2"}],
"mail":[{"value":"name2@email.com"}],
"pass":[{"value":"123456"}]
}
I am sending this by basic auth turned on

Feature request
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

🇺🇸United States mvsimple

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇱Israel jsacksick

    Why are you making this call as authenticated if I may ask?

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    The same is true for core's /user/register route:

    user.register:
      path: '/user/register'
      defaults:
        _entity_form: 'user.register'
        _title: 'Create new account'
      requirements:
        _access_user_register: 'TRUE'
    
      access_check.user.register:
        class: Drupal\user\Access\RegisterAccessCheck
        tags:
          - { name: access_check, applies_to: _access_user_register }
    
    class RegisterAccessCheck implements AccessInterface {
      public function access(AccountInterface $account) {
        $user_settings = \Drupal::config('user.settings');
        return AccessResult::allowedIf($account->isAnonymous() && $user_settings->get('register') != UserInterface::REGISTER_ADMINISTRATORS_ONLY)->addCacheableDependency($user_settings);
      }
    }
    

    This is intentional.

  • Issue was unassigned.
  • Status changed to Closed: works as designed over 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
Production build 0.71.5 2024