So I added authentication,
now if I go back to my stitch rules here, I have these rules for my products right
and right now I got these default rules where everyone is able to read and write.
Everyone still only means logged in users
and since I disabled anonymous authentication, this can only be email and password users.
So even though it says default, it's not that every visitor can read and write everything, you have
to be logged in. To prove this to you,
let me go back to app.js and temporarily set isAuth to true
so that we start in authenticated mode
and this will reload and it will load the products but it only does so because a stitch behind the scenes
did log us in automatically because it stored our status and local storage.
So let's go to the application local storage and actually clear local storage by right clicking on that
and clearing
and now if you reload that page, you get an error, must authenticate before.
Now of course you could handle this in a more graceful way but this proves to you that only authenticated
users are granted access.
So now I set isAuth to false by default again
and if I now log in with my valid credentials again here, whoops I mistyped
but that's good to see too
but now I enter the valid credentials
and now, that is all loaded and that error you see here only stems from the missing image.
So now this is all working as you can tell
and now we are using mongodb stitch and we don't need to write our own backend which of course can
save us a lot of work and time and still, we have a secure solution.