#Van life project unexpected error

22 messages · Page 1 of 1 (latest)

fervent turtle
#

im opening this project link like after 6 months now its showing firebase error

fervent turtle
#

@tribal vector

pliant imp
fervent turtle
pliant imp
#

go to your firebase console then firestore database, you'll see a rules tab, check if you have sufficient permissions there,

fervent turtle
#

@pliant imp

torpid nymph
#

So that date that is listed in the rules is created by firebase for testing purposes. It has long since expire so you need to update your rules. If you are using authentication and only want authenticated users to read or write data, then you would change “allow read, write: if request.time < time stamp….” To “allow read, write: if request.auth != null”. If you want everyone without being authenticated to read and write, you could do “allow read, write: if true” if I recall correctly. You can do a different rule for read and another one for write as well.

fervent turtle
#

service cloud.firestore {
  match /databases/{database}/documents {

    // This rule allows anyone with your Firestore database reference to view, edit,
    // and delete all data in your Firestore database. It is useful for getting
    // started, but it is configured to expire after 30 days because it
    // leaves your app open to attackers. At that time, all client
    // requests to your Firestore database will be denied.
    //
    // Make sure to write security rules for your app before that time, or else
    // all client requests to your Firestore database will be denied until you Update
    // your rules
    match /{document=**} {
      allow read, write: if request.auth!= null;
    }
  }
}```

is this correct ?

but still im getting error
torpid nymph
#

I think you need a space between “auth” and “!”. But also, if you are using firestore to show vans to people who are not logged in, then you will need to set the rule to “allow read: if true”. If you want people who are not logged in to be able to add vans (write to firestore database), then you need to make it “allow read, write: if true”.

#

You don’t want the user to have to be logged in to get the data from firestore if the intent of the site is to hold vans data for anyone to see on the site whether they are logged in or not. Does this make sense?

fervent turtle
#

i didnt mention this before sry for the confusion

torpid nymph
#

So you are using firebase authentication, email and password method?

#

It’s been a while since I did the vans and I think they were using mirage.js to “host” the vans. Aren’t there vans for people to view who having signed up for an account yet? If that data is stored in a firestore collection, then the rule would have to be “allow read, write: if true”. If there are details for hosts or authenticated users in a different firestore collection, you can make that rule :if auth != null.

fervent turtle
#

yeah all the details are stored in firebase

#

this is ok right?

torpid nymph
#

When someone first visits your site, and they aren’t authenticated yet, do you want to show vans or just a login/signup screen? If you want to show vans (but maybe not all the details that the host sees), Set the rule to “allow read, write: if true”. This should solve your immediate issue. If the only thing someone sees when they visit the site is a login/signup page and you don’t need that van data yet, then the rule you have should work. If you want to further refine your rules, I’d have to see your code. Does everyone who isn’t authenticated need write access (probably not) - I don’t know without seeing your code.

fervent turtle