Class: ActionDispatch::Routing::Mapper
- Inherits:
-
Object
- Object
- ActionDispatch::Routing::Mapper
- Defined in:
- lib/auth/rails/routes.rb
Instance Method Summary collapse
-
#mount_routes(app_route_resources) ⇒ Object
key:resource -> the name of the resource for which omniauth routes are to be generated.
Instance Method Details
#mount_routes(app_route_resources) ⇒ Object
key:resource -> the name of the resource for which omniauth routes are to be generated. value:opts -> the options specifying the views, controllers etc for omniauth. expected to be present in the preinitializer in the routes of the target app.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/auth/rails/routes.rb', line 8 def mount_routes(app_route_resources) resources :search, :controller => "auth/search" do collection do get 'authenticated_user_search', :action => 'authenticated_user_search', :as => "authenticated_user" end end ## this controller may need to be changed, actually will have to be changed for every single thing. resources :assemblies, :controller => Auth.configuration.assembly_controller resources :stages, :controller => Auth.configuration.stage_controller resources :sops, :controller => Auth.configuration.sop_controller resources :steps, :controller => Auth.configuration.step_controller resources :orders, :controller => Auth.configuration.order_controller resources :requirements, :controller => Auth.configuration.requirement_controller resources :states, :controller => Auth.configuration.state_controller resources :locations, :controller => Auth.configuration.location_controller resources :schedules, :controller => Auth.configuration.schedule_controller resources :bookings, :controller => Auth.configuration.booking_controller resources :slots, :controller => Auth.configuration.slot_controller resources :overlaps, :controller => Auth.configuration.overlap_controller resources :minutes, :controller => Auth.configuration.minute_controller resources :entities, :controller => Auth.configuration.entity_controller resources :specifications, :controller => Auth.configuration.specification_controller ## image controller is required by default. ## #resources :images, :controller => Auth.configuration.image_controller resources :admin_create_users, :controller => "auth/admin_create_users" resources :clients, :controller => "auth/clients", :as => "auth_clients" resources :profiles, :controller => "auth/profiles" do collection do ## :resource will be something like users. post ':resource/set_proxy_user', :action => 'set_proxy_resource', :as => "set_proxy_resource" get 'credential_exists', :action => 'credential_exists' post ':resource/get_user_id', :action => 'get_user_id' put ':resource/update', :action => 'update' end end if Auth.configuration.otp_controller get "#{Auth.configuration.mount_path}/:resource/otp_verification_result", :action => "otp_verification_result", :controller => "#{Auth.configuration.otp_controller}", :as => "otp_verification_result" get "#{Auth.configuration.mount_path}/:resource/verify_otp", :action => "verify_otp", :controller => "#{Auth.configuration.otp_controller}", :as => "verify_otp" get "#{Auth.configuration.mount_path}/:resource/send_sms_otp", :action => "send_sms_otp", :controller => "#{Auth.configuration.otp_controller}", :as => "send_sms_otp" get "#{Auth.configuration.mount_path}/:resource/resend_sms_otp", :action => "resend_sms_otp", :controller => "#{Auth.configuration.otp_controller}", :as => "resend_sms_otp" end ["cart_item","cart","payment","product","discount","image"].each do |model| if Auth.configuration.send("#{model}_controller") scope_path = "/" as_prefix = nil collection = nil Auth.configuration.send("#{model}_class").underscore.pluralize.scan(/(?<scope_path>.+?)\/(?<collection>[A-Za-z_]+)$/) do if Regexp.last_match[:scope_path] scope_path = scope_path + Regexp.last_match[:scope_path] ## this is done so that the route helper defined inside the engine views also work. as_prefix = Regexp.last_match[:scope_path] end collection = Regexp.last_match[:collection] end if collection scope :path => scope_path, :as => as_prefix do #puts "As prefix is: #{as_prefix}" #puts "scope path is: #{scope_path}" controller_name = Auth.configuration.send("#{model}_controller") resources collection.to_sym, controller: controller_name do collection do ## for the option to create multiple cart items at one time. if model == "cart_item" post 'create_multiple', :action => 'create_multiple' end end end ##A ROUTE HAS BEEN ADDED IN THE DAUGHTER APP FOR THE POST -> TO THE PAYMENTS_UPDATE FOR PAYUMONEY. ##refer payumoney_controller_concern.rb end end end end app_route_resources.each do |resource,opts| #puts "resource is : #{resource}" #puts "opts are: #{opts}" # ensure objects exist to simplify attr checks opts[:controllers] ||= {} opts[:skip] ||= [] # check for ctrl overrides, fall back to defaults sessions_ctrl = opts[:controllers][:sessions] || "auth/sessions" registrations_ctrl = opts[:controllers][:registrations] || "auth/registrations" passwords_ctrl = opts[:controllers][:passwords] || "auth/passwords" confirmations_ctrl = opts[:controllers][:confirmations] || "auth/confirmations" omniauth_ctrl = opts[:controllers][:omniauth_callbacks] || "auth/omniauth_callbacks" unlocks_ctrl = opts[:controllers][:unlocks] || "auth/unlocks" # define devise controller mappings controllers = {:sessions => sessions_ctrl, :registrations => registrations_ctrl, :passwords => passwords_ctrl, :confirmations => confirmations_ctrl, :unlocks => unlocks_ctrl } # remove any unwanted devise modules opts[:skip].each{|item| controllers.delete(item)} resource_as_pluralized_string = Auth::OmniAuth::Path.resource_pluralized(resource) devise_for resource_as_pluralized_string.to_sym, :class_name => resource, :module => :devise, :path => "#{Auth::OmniAuth::Path.resource_path(resource)}", :controllers => controllers, :skip => opts[:skip] + [:omniauth_callbacks] resource_class = Object.const_get resource ################################################################# ## ## OMNIAUTH PATHS ## ################################################################# if !(opts[:skip].include? :omniauthable) resource_class.omniauth_providers.each do |provider| omniauth_request_path = Auth::OmniAuth::Path.omniauth_request_path(nil,provider) common_callback_path = Auth::OmniAuth::Path.common_callback_path(provider) if !Rails.application.routes.url_helpers.method_defined?("#{provider}_omniauth_authorize_path".to_sym) puts "calling route for provider: #{provider}" match "#{omniauth_request_path}", controller: omniauth_ctrl, action: "passthru", via: [:get,:post], as: "#{provider}_omniauth_authorize" end if !Rails.application.routes.url_helpers.method_defined?("#{provider}_omniauth_callback_path".to_sym) match "#{common_callback_path}", controller: omniauth_ctrl, action: "omni_common", via: [:get,:post], as: "#{provider}_omniauth_callback" end end oauth_failure_route_path = Auth::OmniAuth::Path.omniauth_failure_route_path(nil) if !Rails.application.routes.url_helpers.method_defined?("omniauth_failure_path".to_sym) match "#{oauth_failure_route_path}", controller: omniauth_ctrl, action: "failure", via:[:get,:post], as: "omniauth_failure" end end ################################################################# ## ## RESOURCE_PROFILE PATHS ## ################################################################# #match "#{omniauth_request_path}", controller: omniauth_ctrl, action: "passthru", via: [:get,:post], as: "#{provider}_omniauth_authorize" end end |