github / opensourcefriday

🚲 Contribute to the open source community every Friday
https://opensourcefriday.com
MIT License
1.18k stars 160 forks source link

Rescue and handle Octokit::Unauthorized when viewing user pages #1243

Closed jonabc closed 2 years ago

jonabc commented 2 years ago

It's possible for a user's OAuth token to get invalidated by whoever manages the connected OpenSourceFriday OAuth app on GitHub. With the current behavior, the user will be shown a 500 error page which doesn't describe what went wrong or how to fix it.

Fixing the problem is pretty straightforward though, the user needs to sign out and sign back in to go through the OAuth flow again and generate a new token. To give a better overall experience, I've updated the UsersController#show action to catch the error when it occurs and then

I reproduced the issue when running the app locally per the README instructions (🙇 very helpful!) and with the change in this PR the user will end up seeing the following after being redirected:

Screen Shot 2022-04-20 at 5 50 40 PM

I added the token to the english localization file but I don't speak the other languages to supply non-english translations.

MikeMcQuaid commented 2 years ago

Thanks for the PR @jonabc but this site has now been ported to GitHub Pages so this is no longer needed!