UX: Improve error handling for common OmniAuth exceptions (#7991)

This displays more useful messages for the most common issues we see:
- CSRF (when the user switches browser)
- Invalid IAT (when the server clock is wrong)
- OAuth::Unauthorized for OAuth1 providers, when the credentials are incorrect

This commit also stops earlier for disabled authenticators. Now we stop at the request phase, rather than the callback phase.
This commit is contained in:
David Taylor
2019-08-12 10:55:02 +01:00
committed by GitHub
parent 731f61a818
commit 750802bf56
6 changed files with 65 additions and 8 deletions

View File

@ -91,7 +91,8 @@ class Users::OmniauthCallbacksController < ApplicationController
end
def failure
flash[:error] = I18n.t("login.omniauth_error")
error_key = params[:message].to_s.gsub(/[^\w-]/, "") || "generic"
flash[:error] = I18n.t("login.omniauth_error.#{error_key}", default: I18n.t("login.omniauth_error.generic"))
render 'failure'
end