Skip to content

Commit 5b03a6e

Browse files
committed
Merge pull request #2062 from jvortmann/fix_logout_path_and_method
Fix #1386 by removing dependency of Devise for logout_path and logout_method.
2 parents f420baa + 6f4dd05 commit 5b03a6e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

app/helpers/rails_admin/application_helper.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,17 @@ def edit_user_link
3131
end
3232

3333
def logout_path
34-
return unless defined?(Devise)
35-
scope = Devise::Mapping.find_scope!(_current_user)
36-
main_app.send("destroy_#{scope}_session_path") rescue false
34+
if defined?(Devise)
35+
scope = Devise::Mapping.find_scope!(_current_user)
36+
main_app.send("destroy_#{scope}_session_path") rescue false
37+
else
38+
main_app.logout_path if main_app.respond_to?(:logout_path)
39+
end
40+
end
41+
42+
def logout_method
43+
return Devise.sign_out_via if defined?(Devise)
44+
:delete
3745
end
3846

3947
def wording_for(label, action = @action, abstract_model = @abstract_model, object = @object)

app/views/layouts/rails_admin/_secondary_navigation.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
- if user_link = edit_user_link
88
%li= user_link
99
- if logout_path.present?
10-
%li= link_to content_tag('span', t('admin.misc.log_out'), class: 'label label-important'), logout_path, method: Devise.sign_out_via
10+
%li= link_to content_tag('span', t('admin.misc.log_out'), class: 'label label-important'), logout_path, method: logout_method
1111
- if _current_user.respond_to?(:email) && _current_user.email.present?
1212
%li= image_tag "#{(request.ssl? ? 'https://secure' : 'http://www')}.gravatar.com/avatar/#{Digest::MD5.hexdigest _current_user.email}?s=30", style: 'padding-top:5px'

0 commit comments

Comments
 (0)