3

I got custom registration form under /user/register URL but anonymous user gets denied access what type of permissions should I set.
I tried:

 requirements:
   _permission: 'access content'

and

requirements:
   _permission: 'none'

or I deleted it completly but it didn't help.

10

'access content' should be good in general, check it under "people/permissions" to seem if also anonymous users have right to "access content". You can also declare:

_access: 'TRUE'

In this case you don't need the permission part, this one should definitely work!

3
  • It is working. I accidentialy might have turn off access content for anonymous users. Thanks for feedback. – karoluS Jul 4 '17 at 10:59
  • 2
    It should be 'TRUE' as string – Mohamed Osama Gbril Jan 7 '19 at 13:02
  • True: even tho without string it's also working, string shall be used in all cases. – ssibal Jan 7 '19 at 13:41
3

The above answer did not work until I added the quote marks around TRUE. See the following YAML example placed in my_module.routing.yml

my.module:
    path: '/my-module'
    defaults:
      _controller: '\Drupal\my_module\Controller\MyModuleController::connection'
    requirements:
      _access: 'TRUE'
0

The most correct way is use the _persmission as following:

custom_module.add:
  path: '/tools/add'
  defaults:
    _title: 'Add new tools'
    _controller: '\Drupal\custom_module\Controller\ToolsInputPage::render'
  requirements:
    _permission: 'access content'
-3

Try this.

  requirements:
    _role: 'authenticated'

or use the User service.

  requirements:
    _user_is_logged_in: 'TRUE'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.