I am working on this project which has
- franchise --> website --> jsr_franchise.com
- customer --> website --> jsr_customer.com
I am using phone authentication Only. both use same authentication to login
how do i distinguish wherther user logged in from customer franchise website? When I use firebase function
exports.new_User_Added = functions.auth.user()
.onCreate(async (user) => {
database.ref(`/accountCreation/${user.uid}/phoneNumber/`).set(user.phoneNumber)
database.ref(`/accountCreation/${user.uid}/TIMESTAMP/`).set(admin.database.ServerValue.TIMESTAMP)
return Promise.resolve()
})
I am able to get phone number and time stamp. But how do I determine? Whether your user used Customer website or franchise website to authenticate.
CodePudding user response:
With Firebase Authentication a user doesn't log in to a specific site, but they log in to the entire Firebase project. No information about what site triggered that log-in is passed to Cloud Functions.
The most common workaround I know of is to pass all the information that is needed to create the user into a callable Cloud Function or HTTP Cloud Function, create the account there, set a custom claim on their profile with the extra information you want to maintain, and only then sign the user in on the client.