1

How to get current user email like there is a event called onCreate but i want to trigger onLogin or currentUser?

exports.currentUser = functions.auth.user().onCreate((user) => {

const email = user.email; // The email of the user.
const displayName = user.displayName; // The display name of the user.
});
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Ahsan Mani
  • 31
  • 6
  • Possible duplicate of [Cloud Functions for Firebase - Get current user id](https://stackoverflow.com/questions/45613769/cloud-functions-for-firebase-get-current-user-id) – ArunPratap Jul 29 '19 at 15:17
  • With Firebase Authentication triggers you can only trigger a Cloud Function in response to the **creation** and **deletion** of a Firebase user account. See https://firebase.google.com/docs/functions/auth-events – Renaud Tarnec Jul 29 '19 at 15:22
  • @RenaudTarnec but i want to trigger it on login in or other method to do this – Ahsan Mani Jul 29 '19 at 15:41

1 Answers1

0

There are no Cloud Functions triggers for when a user signs in to your app with Firebase Authentication. If you have something to do what the user signs in, that should be controlled by the app itself, since it has the callback for signin and signout. You could directly invoke an HTTP or callable type function in that case, and pass the function the UID to look up using the Firebase Admin SDK.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441