How could i make a firestore cloud function trigger on user login?
up vote
0
down vote
favorite
Cloud functions doesn't accept onLoging by default, how can i "bypass" this limitation so i can run a cloud function every time a user gets "online".
My thought so far is to run a create document on logIn and listen to it, but what happens when the user is not login in but using his last time session?
Do i run the same post request on the isLogged function ? that function can be run many times when the application is running, so is not optimal.
is running the function on app init (angular 7) the solution here?
firebase-authentication google-cloud-firestore google-cloud-functions
add a comment |
up vote
0
down vote
favorite
Cloud functions doesn't accept onLoging by default, how can i "bypass" this limitation so i can run a cloud function every time a user gets "online".
My thought so far is to run a create document on logIn and listen to it, but what happens when the user is not login in but using his last time session?
Do i run the same post request on the isLogged function ? that function can be run many times when the application is running, so is not optimal.
is running the function on app init (angular 7) the solution here?
firebase-authentication google-cloud-firestore google-cloud-functions
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Cloud functions doesn't accept onLoging by default, how can i "bypass" this limitation so i can run a cloud function every time a user gets "online".
My thought so far is to run a create document on logIn and listen to it, but what happens when the user is not login in but using his last time session?
Do i run the same post request on the isLogged function ? that function can be run many times when the application is running, so is not optimal.
is running the function on app init (angular 7) the solution here?
firebase-authentication google-cloud-firestore google-cloud-functions
Cloud functions doesn't accept onLoging by default, how can i "bypass" this limitation so i can run a cloud function every time a user gets "online".
My thought so far is to run a create document on logIn and listen to it, but what happens when the user is not login in but using his last time session?
Do i run the same post request on the isLogged function ? that function can be run many times when the application is running, so is not optimal.
is running the function on app init (angular 7) the solution here?
firebase-authentication google-cloud-firestore google-cloud-functions
firebase-authentication google-cloud-firestore google-cloud-functions
asked Nov 11 at 12:31
yejielw
34
34
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
You can create a function that triggers when a Firebase user is created using the functions.auth.user().onCreate() event handler:
exports.sendWelcomeEmail = functions.auth.user().onCreate((user) => {
// ...
});
https://firebase.google.com/docs/functions/auth-events?hl=en-419
but one alternative you have would be , to make a write operation in the client when user login.
but what if the user is already logged on the server.
– yejielw
Nov 11 at 15:02
You can code a script to make the operations one time, to get the neccesary data, if you need move data.
– Mike Brian Olivera
Nov 11 at 15:05
i would need it one time every time the user comes online
– yejielw
Nov 11 at 15:17
It's not possible from the server-side. look this: cloud.google.com/functions/docs/calling/firebase-auth
– Mike Brian Olivera
Nov 11 at 15:28
add a comment |
up vote
0
down vote
Only you can define what a "session" is for your app. There is no universal definition that you can use to trigger a Cloud Function. Firebase Authentication won't help with this either, since users are logged in "forever", until your code explicitly logs them out (it automatically refreshes the user's auth token every hour).
You're going to have to write your own code to figure this out by whatever specification you decide the user has "logged in" or "logged out".
figured that out, going to use an http call for the function in the end.
– yejielw
Nov 12 at 9:24
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can create a function that triggers when a Firebase user is created using the functions.auth.user().onCreate() event handler:
exports.sendWelcomeEmail = functions.auth.user().onCreate((user) => {
// ...
});
https://firebase.google.com/docs/functions/auth-events?hl=en-419
but one alternative you have would be , to make a write operation in the client when user login.
but what if the user is already logged on the server.
– yejielw
Nov 11 at 15:02
You can code a script to make the operations one time, to get the neccesary data, if you need move data.
– Mike Brian Olivera
Nov 11 at 15:05
i would need it one time every time the user comes online
– yejielw
Nov 11 at 15:17
It's not possible from the server-side. look this: cloud.google.com/functions/docs/calling/firebase-auth
– Mike Brian Olivera
Nov 11 at 15:28
add a comment |
up vote
0
down vote
You can create a function that triggers when a Firebase user is created using the functions.auth.user().onCreate() event handler:
exports.sendWelcomeEmail = functions.auth.user().onCreate((user) => {
// ...
});
https://firebase.google.com/docs/functions/auth-events?hl=en-419
but one alternative you have would be , to make a write operation in the client when user login.
but what if the user is already logged on the server.
– yejielw
Nov 11 at 15:02
You can code a script to make the operations one time, to get the neccesary data, if you need move data.
– Mike Brian Olivera
Nov 11 at 15:05
i would need it one time every time the user comes online
– yejielw
Nov 11 at 15:17
It's not possible from the server-side. look this: cloud.google.com/functions/docs/calling/firebase-auth
– Mike Brian Olivera
Nov 11 at 15:28
add a comment |
up vote
0
down vote
up vote
0
down vote
You can create a function that triggers when a Firebase user is created using the functions.auth.user().onCreate() event handler:
exports.sendWelcomeEmail = functions.auth.user().onCreate((user) => {
// ...
});
https://firebase.google.com/docs/functions/auth-events?hl=en-419
but one alternative you have would be , to make a write operation in the client when user login.
You can create a function that triggers when a Firebase user is created using the functions.auth.user().onCreate() event handler:
exports.sendWelcomeEmail = functions.auth.user().onCreate((user) => {
// ...
});
https://firebase.google.com/docs/functions/auth-events?hl=en-419
but one alternative you have would be , to make a write operation in the client when user login.
answered Nov 11 at 14:58
Mike Brian Olivera
3651513
3651513
but what if the user is already logged on the server.
– yejielw
Nov 11 at 15:02
You can code a script to make the operations one time, to get the neccesary data, if you need move data.
– Mike Brian Olivera
Nov 11 at 15:05
i would need it one time every time the user comes online
– yejielw
Nov 11 at 15:17
It's not possible from the server-side. look this: cloud.google.com/functions/docs/calling/firebase-auth
– Mike Brian Olivera
Nov 11 at 15:28
add a comment |
but what if the user is already logged on the server.
– yejielw
Nov 11 at 15:02
You can code a script to make the operations one time, to get the neccesary data, if you need move data.
– Mike Brian Olivera
Nov 11 at 15:05
i would need it one time every time the user comes online
– yejielw
Nov 11 at 15:17
It's not possible from the server-side. look this: cloud.google.com/functions/docs/calling/firebase-auth
– Mike Brian Olivera
Nov 11 at 15:28
but what if the user is already logged on the server.
– yejielw
Nov 11 at 15:02
but what if the user is already logged on the server.
– yejielw
Nov 11 at 15:02
You can code a script to make the operations one time, to get the neccesary data, if you need move data.
– Mike Brian Olivera
Nov 11 at 15:05
You can code a script to make the operations one time, to get the neccesary data, if you need move data.
– Mike Brian Olivera
Nov 11 at 15:05
i would need it one time every time the user comes online
– yejielw
Nov 11 at 15:17
i would need it one time every time the user comes online
– yejielw
Nov 11 at 15:17
It's not possible from the server-side. look this: cloud.google.com/functions/docs/calling/firebase-auth
– Mike Brian Olivera
Nov 11 at 15:28
It's not possible from the server-side. look this: cloud.google.com/functions/docs/calling/firebase-auth
– Mike Brian Olivera
Nov 11 at 15:28
add a comment |
up vote
0
down vote
Only you can define what a "session" is for your app. There is no universal definition that you can use to trigger a Cloud Function. Firebase Authentication won't help with this either, since users are logged in "forever", until your code explicitly logs them out (it automatically refreshes the user's auth token every hour).
You're going to have to write your own code to figure this out by whatever specification you decide the user has "logged in" or "logged out".
figured that out, going to use an http call for the function in the end.
– yejielw
Nov 12 at 9:24
add a comment |
up vote
0
down vote
Only you can define what a "session" is for your app. There is no universal definition that you can use to trigger a Cloud Function. Firebase Authentication won't help with this either, since users are logged in "forever", until your code explicitly logs them out (it automatically refreshes the user's auth token every hour).
You're going to have to write your own code to figure this out by whatever specification you decide the user has "logged in" or "logged out".
figured that out, going to use an http call for the function in the end.
– yejielw
Nov 12 at 9:24
add a comment |
up vote
0
down vote
up vote
0
down vote
Only you can define what a "session" is for your app. There is no universal definition that you can use to trigger a Cloud Function. Firebase Authentication won't help with this either, since users are logged in "forever", until your code explicitly logs them out (it automatically refreshes the user's auth token every hour).
You're going to have to write your own code to figure this out by whatever specification you decide the user has "logged in" or "logged out".
Only you can define what a "session" is for your app. There is no universal definition that you can use to trigger a Cloud Function. Firebase Authentication won't help with this either, since users are logged in "forever", until your code explicitly logs them out (it automatically refreshes the user's auth token every hour).
You're going to have to write your own code to figure this out by whatever specification you decide the user has "logged in" or "logged out".
answered Nov 11 at 17:57
Doug Stevenson
66.5k87997
66.5k87997
figured that out, going to use an http call for the function in the end.
– yejielw
Nov 12 at 9:24
add a comment |
figured that out, going to use an http call for the function in the end.
– yejielw
Nov 12 at 9:24
figured that out, going to use an http call for the function in the end.
– yejielw
Nov 12 at 9:24
figured that out, going to use an http call for the function in the end.
– yejielw
Nov 12 at 9:24
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248790%2fhow-could-i-make-a-firestore-cloud-function-trigger-on-user-login%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown