2017-12-21 17:36:29 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2011-06-24 19:34:13 +00:00
|
|
|
class Devise::OmniauthCallbacksController < DeviseController
|
2015-08-18 23:42:56 +00:00
|
|
|
prepend_before_action { request.env["devise.skip_timeout"] = true }
|
2012-06-16 11:24:07 +00:00
|
|
|
|
2012-06-16 11:42:24 +00:00
|
|
|
def passthru
|
2017-05-03 03:31:52 +00:00
|
|
|
render status: 404, plain: "Not found. Authentication passthru."
|
2012-06-16 11:42:24 +00:00
|
|
|
end
|
|
|
|
|
2010-10-14 21:46:10 +00:00
|
|
|
def failure
|
2014-02-25 16:42:55 +00:00
|
|
|
set_flash_message :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message
|
2010-10-14 23:15:17 +00:00
|
|
|
redirect_to after_omniauth_failure_path_for(resource_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def failed_strategy
|
2016-06-18 13:20:08 +00:00
|
|
|
request.respond_to?(:get_header) ? request.get_header("omniauth.error.strategy") : request.env["omniauth.error.strategy"]
|
2010-10-14 23:15:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def failure_message
|
2016-06-18 13:20:08 +00:00
|
|
|
exception = request.respond_to?(:get_header) ? request.get_header("omniauth.error") : request.env["omniauth.error"]
|
2010-10-14 23:15:17 +00:00
|
|
|
error = exception.error_reason if exception.respond_to?(:error_reason)
|
|
|
|
error ||= exception.error if exception.respond_to?(:error)
|
2016-06-18 13:20:08 +00:00
|
|
|
error ||= (request.respond_to?(:get_header) ? request.get_header("omniauth.error.type") : request.env["omniauth.error.type"]).to_s
|
2010-10-14 23:15:17 +00:00
|
|
|
error.to_s.humanize if error
|
|
|
|
end
|
|
|
|
|
|
|
|
def after_omniauth_failure_path_for(scope)
|
|
|
|
new_session_path(scope)
|
2010-10-14 21:46:10 +00:00
|
|
|
end
|
2015-01-07 13:35:45 +00:00
|
|
|
|
|
|
|
def translation_scope
|
|
|
|
'devise.omniauth_callbacks'
|
|
|
|
end
|
2011-02-24 19:50:22 +00:00
|
|
|
end
|