We have an oauth-based authentication strategy, but I would like to be able
to restore req.user based on an access token I have stored off that may
outlast the session.
When the stored access token is still valid, but for whatever reason the
browser session is gone and req.user no longer exists, what would be the
best way to restore req.user without going through the oauth sign-in
screen. I can use the stored access token to fetch the user profile, but I
don't know the best way to integrate that into req.user.
Would it be to override authenticate() in our oauth-based strategy and do a
token validation prior to calling oauth.authenticate()? Is there some
middleware I can add to validate the access token and restore the user in a
more integrated way? I can think of a few ways, but I'm not sure which
would be best.