Cloud Functions for Firebase: get actual timestamp of database -


i need actual timestamp of firebase database servers instead of placeholder firebase.database.servervalue.timestamp.

in order avoid xy problem, provide 2 use cases:

a) have created own reset password system using cloud functions , jwt. user requests reset password. sign object containing username , current timestamp(currently using date.now()) , send embedded link email. when open link, need verify jwt , compare timestamp stored under uid in firebase database. update timestamp in database next time try use same token, show expired(even if 1 hour expiration have set token has not passed). using date.now() here enough? how can pass current firebase time jwt.sign().

b) need store negative version of creationtimestamp of posts in database sorting purposes. -firebase.database.servervalue.timestamp not work. correct way that?

google goes through great trouble make sure of servers have times closely synchronized possible. so, if you're running code in cloud functions, ends on google server, , want know time on google server (like realtime database), use date.now(). there's no need use special database token timestamp when running in cloud functions.

that timestamp token intended useful when code running on client devices clocks may not synchronized.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -