module Refinery::Authentication::Devise::System
Public Instance Methods
after_sign_in_path_for(resource_or_scope)
click to toggle source
This just defines the devise method for after sign in to support extension namespace isolation…
# File lib/refinery/authentication/devise/system.rb, line 48 def after_sign_in_path_for(resource_or_scope) pop_stored_location || sanitized_stored_location_for(resource_or_scope) || signed_in_root_path(resource_or_scope) end
after_sign_out_path_for(resource_or_scope)
click to toggle source
# File lib/refinery/authentication/devise/system.rb, line 54 def after_sign_out_path_for(resource_or_scope) refinery.login_path end
signed_in_root_path(resource_or_scope)
click to toggle source
This defines the devise method for refinery routes
# File lib/refinery/authentication/devise/system.rb, line 24 def signed_in_root_path(resource_or_scope) scope = ::Devise::Mapping.find_scope!(resource_or_scope) home_path = "#{scope}_root_path" if respond_to?(home_path, true) refinery.send(home_path) else Refinery::Core.backend_path end end
Protected Instance Methods
pop_stored_location()
click to toggle source
Clear and return the stored location
# File lib/refinery/authentication/devise/system.rb, line 13 def pop_stored_location session.delete(:return_to) end
redirect_back_or_default(default)
click to toggle source
Redirect to the URI stored by the most recent store_location
call or to the passed default.
# File lib/refinery/authentication/devise/system.rb, line 19 def redirect_back_or_default(default) redirect_to(pop_stored_location || default) end
sanitized_stored_location_for(resource_or_scope)
click to toggle source
Pops the stored url, trims the sneaky “//” from it, and returns it.
Making sure bad urls aren't stored in the first place should probably be a part of the Devise::FailureApp
# File lib/refinery/authentication/devise/system.rb, line 38 def sanitized_stored_location_for(resource_or_scope) # `stored_location_for` is the devise method that pops the # scoped `return_to` key location = stored_location_for(resource_or_scope) location.sub!("//", "/") if location.respond_to?(:sub!) location end
store_location()
click to toggle source
Store the URI of the current request in the session.
We can return to this location by calling redirect_back_or_default
.
# File lib/refinery/authentication/devise/system.rb, line 8 def store_location session[:return_to] = request.fullpath end