0

there is a web application built on Vue + Firebase. The question is how to automatically enter the application after the page is reloaded, how to later log in to your database, as far as I understand after authorization, all such data remains for example

fb.auth().onAuthStateChanged(user => {
console.log(user) // user profile
}

So I can get the user's email and uid, so firebase thinks I'm an authorized user, and allows me to edit and read data with rules:

".read": "auth != null",
".write": "auth != null"

However, on the Authentication tab, there is a field for each user "Last Login Date" and it is not updated until the "Normal" authorization by email password for example.

I'll repeat the question of how to authorize in my database after rebooting the page in the browser, is there any special method for this? Thank you in advance)

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

There is no way for your application code or configuration to affect when Firebase updates the Last Login Date. Well... you could require your user to re-authenticate, but I doubt that is what you want, and it can be bypassed by your users.

It sounds like you want to know when the user last started you application, which is something different from when they last logged in. To track when the user starts the application, consider using an analytics package.

Alternatively you can write a "lastSeen" value to the database whenever the onAuthStateChanged fires with a user profile. Something like this would do that for the Firebase Realtime Database:

firebase.database().ref("lastSeen").child(user.uid).set(firebase.database.ServerValue.TIMESTAMP);
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • I'm just worried about the authorization of the user, due to the fact that it is not updated in the field "Last login date" thought that in fact the user is not logged in firebase. As far as I understand, all the same, firebase is automatically authorized, is it so? – Flashantik Jul 30 '18 at 09:07
  • I'm not sure I understand your last comment. But if you're asking whether authentication sessions automatically expire: [they don't](https://stackoverflow.com/questions/37487283/firebase-3-x-token-session-expiration). – Frank van Puffelen Jul 30 '18 at 14:11