Comments (4)
functions/db/admins/onWrite.f.js:
import { database } from 'firebase-functions'
import admin from 'firebase-admin'
exports = module.exports = database
.ref('/admins/{userUid}')
.onWrite((change, context) => {
const userUid = context.params.userUid
if(change.before.exists()){
if(!change.after.exists())
return admin.firestore().collection('admins').doc(userUid).delete();
} else if(change.after.exists())
return admin.firestore().collection('admins').doc(userUid).set({});
return null;
})
functions/db/userGrants/onWrite.f.js:
import { database } from 'firebase-functions'
import admin from 'firebase-admin'
exports = module.exports = database
.ref('/user_grants/{userUid}/{grantName}')
.onWrite((eventSnapshot, context) => {
const userUid = context.params.userUid
const grantName = context.params.grantName
let prm = {}
if (eventSnapshot.after.val()) {
prm[grantName] = true;
} else {
prm[grantName] = false;
}
return admin.firestore().collection('user_grants').doc(userUid).set(prm, {merge:true});
})
I added the above for now to duplicate privilege changes from the RDB into Firestore. It seems to be working in case anyone else is stumped by the issue.
Would appreciate an official word on how this should be handled! :)
from react-most-wanted.
Hi @linusmartensson there should be a sync from RTD to Firestore. We do it the same in our company.
from react-most-wanted.
omg it seems I frogot to put the sync in the demo -.-
from react-most-wanted.
Updated the project to have integrated sync of admins and grants to firestore. Also to sync admins and grants with "storage" in it's name to the custom auth tokens. Because you can't access RTD and Firestore on the storage rules the only solution is to do it over those custom tokens. Sync of all of them would not fit so we sync only those witch have "storage" in they're name.
from react-most-wanted.
Related Issues (20)
- Hello this is not a big issue, just personal issue HOT 1
- `npm install` fails HOT 1
- Consider generating source maps
- Generated app is not working HOT 2
- Generated app with --template rmw is not working
- Loading icon in rmw-shell template is not centered
- MUI Shell template has a compile error immediately
- Handle routes for react-dom v6 HOT 5
- Generating app with --template rmw intl-relativetimeformat dependency HOT 10
- Can't resolve './config' HOT 1
- Testing tools, Cypress, RTL HOT 1
- Can't login to app HOT 11
- firebase deploy --only functions HOT 26
- RTL Mode
- rmw template fails to install "Conflicting peer dependency" HOT 4
- redirect to previous authenticated path after signing in
- I'm no able to install this template with `npx create-react-app` HOT 13
- npx create-react-app error HOT 11
- Firebase Phone number authentication not working
- Menu - Auth menu list items not rendering when within nested list items
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-most-wanted.