CalNourish / pantry-webapp

Pantry web app built with Next.js
https://www.ucbbncfp.com/
MIT License
8 stars 0 forks source link

add listener for token timeout #170

Closed janiseliang closed 1 year ago

janiseliang commented 1 year ago

onAuthStateChanged only listens for sign-in and sign-out. instead, we can use onIdTokenChanged to listen for sign-in, sign-out, and token update after timeouts

https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#onidtokenchanged

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ucbpfa-pantry-webapp ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 21, 2023 11:00pm
janiseliang commented 1 year ago

the token was getting updated in the userContext, but wasn't getting refreshed in the react component because we were copying props.user into this.state.user when we should have just been using this.props.user directly

should hoooopefully be fixed for good this time!

justinazhang commented 1 year ago

the token was getting updated in the userContext, but wasn't getting refreshed in the react component because we were copying props.user into this.state.user when we should have just been using this.props.user directly

should hoooopefully be fixed for good this time!

packingDetailed and bagPacking also use this.state.user sorry :( should i fix that?

janiseliang commented 1 year ago

the token was getting updated in the userContext, but wasn't getting refreshed in the react component because we were copying props.user into this.state.user when we should have just been using this.props.user directly

should hoooopefully be fixed for good this time!

packingDetailed and bagPacking also use this.state.user sorry :( should i fix that?

whoops i missed those, thanks! i can fix them and i'll also make sure none of the other pages use it

justinazhang commented 1 year ago

the token was getting updated in the userContext, but wasn't getting refreshed in the react component because we were copying props.user into this.state.user when we should have just been using this.props.user directly

should hoooopefully be fixed for good this time!

packingDetailed and bagPacking also use this.state.user sorry :( should i fix that?

whoops i missed those, thanks! i can fix them and i'll also make sure none of the other pages use it

yay thank you sm!!

janiseliang commented 1 year ago

Yay looks good! Also tried this out during open hours and it worked flawlessly :D

yay!! we finally did it :)