nazrinharris / farmhub

App to find out prices of farm produce at a specific location in Malaysia
3 stars 0 forks source link

Create a system to check the minimum app version needed and throw error if needed. #192

Closed nazrinharris closed 1 year ago

nazrinharris commented 1 year ago

Basically, the database now properly reject writes (provided that the user uses app version 0.3.2 and above where custom claims will be implemented), but there will not be a beautiful error message, just a simple permission denied. I will need to implement this version checking client side.

I'm thinking of simply having a new collection called configs and have a document called app-meta, and having a field minimum-app-version. Then whenever there is a major data structure change, this field (and the field in security rules) will be changed.

This will also open a possibility to have a latest-version, and the app will compare against this field to suggest the user to update the app.


Firebase Remote Config seems like a good solution for this rather than a document in firestore, here's the general overview of steps I need to take.

nazrinharris commented 1 year ago

Methods to check version before execution (all write methods in <any>Repository:

nazrinharris commented 1 year ago

In ProduceManagerRepository, it seems like Firestore doesn't properly block admins from creating produce with an app version lower than minimum.

nazrinharris commented 1 year ago

Actually, it seems like the isAppVersionAllowed() in rules doesn't really work

nazrinharris commented 1 year ago

Should be done with e9b143f