3
4
5
6
7
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
|
# File 'lib/devise_token_auth/rails/routes.rb', line 3
def mount_devise_token_auth_for(resource, opts)
scope opts[:at] do
devise_for resource.pluralize.underscore.to_sym,
:class_name => resource,
:module => :devise,
:path => "",
:controllers => {:sessions => "devise_token_auth/sessions",
:registrations => "devise_token_auth/registrations",
:passwords => "devise_token_auth/passwords",
:confirmations => "devise_token_auth/confirmations"}
devise_scope resource.underscore.to_sym do
get "validate_token", to: "devise_token_auth/auth#validate_token"
if defined?(::OmniAuth)
get "failure", to: "devise_token_auth/auth#omniauth_failure"
get ":provider/callback", to: "devise_token_auth/auth#omniauth_success"
post ":provider/callback", to: "devise_token_auth/auth#omniauth_success"
match ":provider", to: redirect{|params, request|
qs = CGI::parse(request.env["QUERY_STRING"])
qs["resource_class"] = [resource]
"#{::OmniAuth::config.path_prefix}/#{params[:provider]}?#{{}.tap {|hash| qs.each{|k, v| hash[k] = v.first}}.to_param}"
}, via: [:get]
end
end
end
end
|