#Access control

28 messages · Page 1 of 1 (latest)

heavy bane
#

When I try to access my ReactJS website to different browser, then it's not working. Need to login Payload admin portal, then its working fine.
How can I access my website without passing any credentials or login in different browser.
I'm using the payload:1.6.32 version.

ashen dome
#

@heavy bane Good morning! This is likely happening because you are not bringing the cookie stored upon a sucessful login with you to the other browser

#

You would have to somehow bring the cookie over to maintain your session as far as I know

#

I can imagine some workarounds in my head, but not sure what your end goal is

pulsar sorrel
#

On your collection you can set the access object to allow read by any one i.e.

  access: {
    read: true,
  }

The template-website repo on the payload github has some examples of this along with a helper.

ashen dome
#

Oh I thought they meant they weren't staying logged in

#

Yeah, this is an access control issue then

#

@pulsar sorrel Doesn't read need to be a function that returns true?

#
access: {
  read: () => true
}
pulsar sorrel
#

yeah that's right

heavy bane
#

First of all thanks to all
How I can access my website without login.
Or how I can provide the public access, so anyone can be access

heavy bane
pulsar sorrel
#

I'm afraid I don't follow what it is exactly you want to do.

heavy bane
#

I'm creating the public website, anyone can access

pulsar sorrel
#

yeah, how are you reading the data from Payload? REST api, graphql or local?

heavy bane
#

REST api

pulsar sorrel
#

if you have the collection set up like so you shouldn't need authentication 🤷‍♂️

access: {
  read: () => true
}

heavy bane
#

I used, but it is not working

unkempt pond
#

make sure you add read access control like the above to each of your collections that you need to retrieve as an unauthenticated user

#

this is 100% the issue as reported above

heavy bane
heavy bane
#

Hi @unkempt pond Good morning, I used this way but it is not working
please check below screenshot

#

This is my payload.config.ts file

#

Could you help me on that?

ashen dome
#

@heavy bane Nothing seems odd in those SS

#

Which part is not working?

#

Setting the "read" access control should have made the collection publicly accessible

#

In addition, since you have an upload field, I think you also need to set the access control on your Media Collection, assuming that content should also be publicly visible