• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mgmodell / devise_token_auth_multi_email / #663

17 Mar 2026 01:12AM UTC coverage: 12.22% (-78.4%) from 90.649%
#663

push

mgmodell
switching back to mult-email

202 of 1653 relevant lines covered (12.22%)

0.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.81
/lib/devise_token_auth/engine.rb
1
# frozen_string_literal: true
2

3
require 'devise_token_auth/rails/routes'
1✔
4

5
module DeviseTokenAuth
1✔
6
  class Engine < ::Rails::Engine
1✔
7
    isolate_namespace DeviseTokenAuth
1✔
8

9
    initializer 'devise_token_auth.url_helpers' do
1✔
10
      Devise.helpers << DeviseTokenAuth::Controllers::Helpers
1✔
11
    end
12
  end
13

14
  mattr_accessor :change_headers_on_each_request,
1✔
15
                 :max_number_of_devices,
16
                 :token_lifespan,
17
                 :token_cost,
18
                 :batch_request_buffer_throttle,
19
                 :omniauth_prefix,
20
                 :default_confirm_success_url,
21
                 :default_password_reset_url,
22
                 :redirect_whitelist,
23
                 :check_current_password_before_update,
24
                 :enable_standard_devise_support,
25
                 :remove_tokens_after_password_reset,
26
                 :default_callbacks,
27
                 :headers_names,
28
                 :cookie_enabled,
29
                 :cookie_name,
30
                 :cookie_attributes,
31
                 :bypass_sign_in,
32
                 :send_confirmation_email,
33
                 :require_client_password_reset_token,
34
                 :other_uid
35

36
  self.change_headers_on_each_request       = true
1✔
37
  self.max_number_of_devices                = 10
1✔
38
  self.token_lifespan                       = 2.weeks
1✔
39
  self.token_cost                           = 10
1✔
40
  self.batch_request_buffer_throttle        = 5.seconds
1✔
41
  self.omniauth_prefix                      = '/omniauth'
1✔
42
  self.default_confirm_success_url          = nil
1✔
43
  self.default_password_reset_url           = nil
1✔
44
  self.redirect_whitelist                   = nil
1✔
45
  self.check_current_password_before_update = false
1✔
46
  self.enable_standard_devise_support       = false
1✔
47
  self.remove_tokens_after_password_reset   = false
1✔
48
  self.default_callbacks                    = true
1✔
49
  self.headers_names                        = { 'authorization': 'Authorization',
1✔
50
                                                'access-token': 'access-token',
51
                                                'client': 'client',
52
                                                'expiry': 'expiry',
53
                                                'uid': 'uid',
54
                                                'token-type': 'token-type' }
55
  self.cookie_enabled                       = false
1✔
56
  self.cookie_name                          = 'auth_cookie'
1✔
57
  self.cookie_attributes                    = {}
1✔
58
  self.bypass_sign_in                       = true
1✔
59
  self.send_confirmation_email              = false
1✔
60
  self.require_client_password_reset_token  = false
1✔
61
  self.other_uid                            = nil
1✔
62

63
  def self.setup(&block)
1✔
64
    yield self
1✔
65

66
    Rails.application.config.after_initialize do
1✔
67
      if defined?(::OmniAuth)
1✔
68
        ::OmniAuth::config.path_prefix = Devise.omniauth_path_prefix = omniauth_prefix
1✔
69

70
        # Omniauth currently does not pass along omniauth.params upon failure redirect
71
        # see also: https://github.com/intridea/omniauth/issues/626
72
        OmniAuth::FailureEndpoint.class_eval do
1✔
73
          def redirect_to_failure
1✔
74
            message_key = env['omniauth.error.type']
×
75
            origin_query_param = env['omniauth.origin'] ? "&origin=#{CGI.escape(env['omniauth.origin'])}" : ''
×
76
            strategy_name_query_param = env['omniauth.error.strategy'] ? "&strategy=#{env['omniauth.error.strategy'].name}" : ''
×
77
            extra_params = env['omniauth.params'] ? "&#{env['omniauth.params'].to_query}" : ''
×
78
            new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}#{origin_query_param}#{strategy_name_query_param}#{extra_params}"
×
79
            Rack::Response.new(['302 Moved'], 302, 'Location' => new_path).finish
×
80
          end
81
        end
82

83
        # Omniauth currently removes omniauth.params during mocked requests
84
        # see also: https://github.com/intridea/omniauth/pull/812
85
        OmniAuth::Strategy.class_eval do
1✔
86
          def mock_callback_call
1✔
87
            setup_phase
×
88
            @env['omniauth.origin'] = session.delete('omniauth.origin')
×
89
            @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''
×
90
            @env['omniauth.params'] = session.delete('omniauth.params') || {}
×
91
            mocked_auth = OmniAuth.mock_auth_for(name.to_s)
×
92
            if mocked_auth.is_a?(Symbol)
×
93
              fail!(mocked_auth)
×
94
            else
95
              @env['omniauth.auth'] = mocked_auth
×
96
              OmniAuth.config.before_callback_phase.call(@env) if OmniAuth.config.before_callback_phase
×
97
              call_app!
×
98
            end
99
          end
100
        end
101

102
      end
103
    end
104
  end
105
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc