Вопрос

I’m using passport (and passport-google-oauth) to auth a user to my web application. When the user logs in, I insert its metadata in my database (name, email, picture, access token & refresh token). But if this user updates their Google profile (e.g changes their name), then my app still has the old data. Should I update my db each time they log in? And then again, should I update it periodically anyway? If so, what is the recommended frequency?

Это было полезно?

Решение

The answer to all of your question is "it depends".

1) Should I update my db each time they log in?

It depends.

  • Why are you saving it at all?
  • How expensive is it to save the data? If cheap, what's the debate?

2) Should I update it periodically anyway?

It depends.

The answers to the two questions, above, will be relevant. But also...

  • Are you using the data when they aren't logged in? If so, what is the cost if the data is wrong?
  • How would you determine what "periodically" means?
  • How do you benefit by not saving every time?
  • What complexity do you add to your code by working in 'do I save it or not' logic? Is it worth it?

3) What is the recommended frequency?

As you can probably guess: It depends...

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top