Hi shreyngd, thank you so much for the kind words and I'm super glad this could be of help to you. You are right about the foundUser not returning the updated token which is wrong. Thanks for spotting that. I will do my best to update the article where needed.
Yes it looks good. If you dont mind some unsolicited advice 😅, you may want to consider the renaming of the function to reflect it's concern of updating tokens only. Using the FindOneAndUpdate method is good but since the fucntion is supposed to only make an update you may resort to another function returning the user object or naming the function accordingly. This is mostly for readability and clean code purposes
This has been the best tutorial on golang + rest + mogo auth so far I have seen.
I have worked on nodejs express applications extensively and recently started to learn Golang. I understand the concept but its hard to code in Go.
So thankyou so much.
Other than that I also implemented this on my git. github.com/shreyngd/booker. I am also be integrating oauth2 in this example.
In the login function, we are returning foundUser at the end, which does not have updated token and refresh token in it, which can cause issues.
Hi shreyngd, thank you so much for the kind words and I'm super glad this could be of help to you. You are right about the foundUser not returning the updated token which is wrong. Thanks for spotting that. I will do my best to update the article where needed.
In my implementation I had used FindOneAndUpdate method github.com/shreyngd/booker/blob/26....
This method returns the updated user. I don't know whether it is correct way.
Yes it looks good. If you dont mind some unsolicited advice 😅, you may want to consider the renaming of the function to reflect it's concern of updating tokens only. Using the FindOneAndUpdate method is good but since the fucntion is supposed to only make an update you may resort to another function returning the user object or naming the function accordingly. This is mostly for readability and clean code purposes
thanks bro, you are a good person