Closed shaunnez closed 5 years ago
Currently, we opted to go with a client-side only connection to your Firebase project, which means we have no way of knowing when a new user is created unless it is something that happens within the app. In the near future, we'll allow project owners to additionally provide us with a service account so that we can perform more of these server-side only operations for some of the more advanced features to come. This will be opt-in.
What I've seen another user do for the scenario you mentioned is to set up a cloud function that listens to new users being created in the app and then you can use the flamelinkApp.users.addToDB()
method to write the user to fl_users
as well.
Yup that's what I've done just wanted to see if it was something I was missing or coming in the future. Thanks! (heres my function)
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
import * as flamelink from 'flamelink/app';
export const onCreateUser = functions.auth.user().onCreate(async (user) => {
try {
const flamelinkApp = flamelink({ firebaseApp: admin.app(), dbType: 'cf' });
const result = await flamelinkApp.users.addToDB({
uid: user.uid,
data: {
displayName: user.email ? user.email.split('@')[0] : '',
email: user.email,
enabled: 'Yes',
permissions: '1'
}
});
console.log('onCreateUser success', result);
} catch (ex) {
console.log('onCreateUser error', ex);
}
});
Perfect 👍 Just out of interest, the permissions
option is currently only used for users inside the Flamelink app.
When a user "registers" with the firebase project, should they not automatically be created in the fl_user schema? E.g. when createUserWithEmailAndPassword happens