PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 20, 2022

[FIXED] how to find from which application user authenticated in firebase authentication

 October 20, 2022     firebase, firebase-authentication, google-cloud-functions, node.js     No comments   

Issue

I am working on this project which has

  1. franchise --> website --> jsr_franchise.com
  2. 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.


Solution

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.



Answered By - Frank van Puffelen
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing