Skip to content
Newer
Older
100644 35 lines (27 sloc) 1.15 KB
2b64c6d @sj26 Make all controllers inherit from a single DeviseController
sj26 authored
1 class Devise::OmniauthCallbacksController < DeviseController
2024fca @twalpole Rails 5 compatability. Remove rails < 4.1 and Ruby < 2.1
twalpole authored
2 prepend_before_action { request.env["devise.skip_timeout"] = true }
41a9118 @josevalim Do not trigger timeout on sign in related actions
josevalim authored
3
b1633f2 @josevalim Delegate omniauth_authorize_path to the router, closes #1843
josevalim authored
4 def passthru
dc1b399 @optimisticanshul Updated ruby 1.9 hash syntax
optimisticanshul authored
5 render status: 404, text: "Not found. Authentication passthru."
b1633f2 @josevalim Delegate omniauth_authorize_path to the router, closes #1843
josevalim authored
6 end
7
2f360bf @josevalim Remove OAuth2 in favor of OmniAuth.
josevalim authored
8 def failure
dc1b399 @optimisticanshul Updated ruby 1.9 hash syntax
optimisticanshul authored
9 set_flash_message :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message
3e38043 @josevalim Properly handle failure.
josevalim authored
10 redirect_to after_omniauth_failure_path_for(resource_name)
11 end
12
13 protected
14
15 def failed_strategy
2024fca @twalpole Rails 5 compatability. Remove rails < 4.1 and Ruby < 2.1
twalpole authored
16 request.respond_to?(:get_header) ? request.get_header("omniauth.error.strategy") : env["omniauth.error.strategy"]
3e38043 @josevalim Properly handle failure.
josevalim authored
17 end
18
19 def failure_message
2024fca @twalpole Rails 5 compatability. Remove rails < 4.1 and Ruby < 2.1
twalpole authored
20 exception = request.respond_to?(:get_header) ? request.get_header("omniauth.error") : env["omniauth.error"]
3e38043 @josevalim Properly handle failure.
josevalim authored
21 error = exception.error_reason if exception.respond_to?(:error_reason)
22 error ||= exception.error if exception.respond_to?(:error)
2024fca @twalpole Rails 5 compatability. Remove rails < 4.1 and Ruby < 2.1
twalpole authored
23 error ||= (request.respond_to?(:get_header) ? request.get_header("omniauth.error.type") : env["omniauth.error.type"]).to_s
3e38043 @josevalim Properly handle failure.
josevalim authored
24 error.to_s.humanize if error
25 end
26
27 def after_omniauth_failure_path_for(scope)
28 new_session_path(scope)
2f360bf @josevalim Remove OAuth2 in favor of OmniAuth.
josevalim authored
29 end
c2fb80d @rosenfeld Use Devise translations when inheriting from core controllers
rosenfeld authored
30
31 def translation_scope
32 'devise.omniauth_callbacks'
33 end
352edc0 @vinibaggio Cleaning up test helpers related to OmniAuth.
vinibaggio authored
34 end
Something went wrong with that request. Please try again.