2010-10-14 21:46:10 +00:00
|
|
|
class Devise::OmniauthCallbacksController < ApplicationController
|
|
|
|
include Devise::Controllers::InternalHelpers
|
|
|
|
|
|
|
|
def failure
|
2010-10-14 23:15:17 +00:00
|
|
|
set_flash_message :alert, :failure, :kind => failed_strategy.name.to_s.humanize, :reason => failure_message
|
|
|
|
redirect_to after_omniauth_failure_path_for(resource_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def failed_strategy
|
2011-02-24 19:50:22 +00:00
|
|
|
env["omniauth.error.strategy"]
|
2010-10-14 23:15:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def failure_message
|
|
|
|
exception = env["omniauth.error"]
|
|
|
|
error = exception.error_reason if exception.respond_to?(:error_reason)
|
|
|
|
error ||= exception.error if exception.respond_to?(:error)
|
2011-02-24 19:50:22 +00:00
|
|
|
error ||= 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
|
2011-02-24 19:50:22 +00:00
|
|
|
end
|