Inclusion hook to make current_ubiquo_user and logged_in? available as ActionView helper methods.
# File vendor/plugins/ubiquo_authentication/lib/ubiquo_authentication/authenticated_system.rb, line 97
97: def self.included(base)
98: base.send :helper_method, :current_ubiquo_user, :logged_in?
99: end
Redirect as appropriate when an access request fails.
The default action is to redirect to the login screen.
Override this method in your controllers if you want to have special behavior in case the ubiquo_user is not authorized to access the requested action. For example, a popup window might simply close itself.
# File vendor/plugins/ubiquo_authentication/lib/ubiquo_authentication/authenticated_system.rb, line 69
69: def access_denied
70: respond_to do |format|
71: format.html do
72: store_location
73: redirect_to ubiquo_login_path
74: end
75: format.any(:js, :xml, :atom, :rss) do
76: request_http_basic_authentication 'Web Password'
77: end
78: end
79: end
Accesses the current ubiquo_user from the session. Set it to :false if login fails so that future calls do not hit the database.
# File vendor/plugins/ubiquo_authentication/lib/ubiquo_authentication/authenticated_system.rb, line 11
11: def current_ubiquo_user
12: # @current_ubiquo_user ||= (login_from_session || login_from_basic_auth || login_from_cookie || :false)
13: @current_ubiquo_user ||= (login_from_session || login_from_cookie || :false)
14: end
Store the given ubiquo_user in the session.
# File vendor/plugins/ubiquo_authentication/lib/ubiquo_authentication/authenticated_system.rb, line 17
17: def current_ubiquo_user=(new_ubiquo_user)
18: session[:ubiquo] ||= {}
19: session[:ubiquo][:ubiquo_user_id] = (new_ubiquo_user.nil? || new_ubiquo_user.is_a?(Symbol)) ? nil : new_ubiquo_user.id
20: @current_ubiquo_user = new_ubiquo_user || :false
21: end
Returns true or false if the ubiquo_user is logged in.
# File vendor/plugins/ubiquo_authentication/lib/ubiquo_authentication/authenticated_system.rb, line 5 5: def logged_in? 6: current_ubiquo_user != :false 7: end
Attempt to login by the ubiquo_user id stored in the session.
# File vendor/plugins/ubiquo_authentication/lib/ubiquo_authentication/authenticated_system.rb, line 102
102: def login_from_session
103: self.current_ubiquo_user = UbiquoUser.find_by_id(session[:ubiquo][:ubiquo_user_id]) if session[:ubiquo] && session[:ubiquo][:ubiquo_user_id]
104: end
Filter method to enforce a login requirement.
To require logins for all actions, use this in your controllers:
before_filter :login_required
To require logins for specific actions, use this in your controllers:
before_filter :login_required, :only => [ :edit, :update ]
To skip this in a subclassed controller:
skip_before_filter :login_required
# File vendor/plugins/ubiquo_authentication/lib/ubiquo_authentication/authenticated_system.rb, line 38
38: def login_required
39: logged_in? || access_denied
40: end
Redirect to the URI stored by the most recent store_location call or to the passed default.
# File vendor/plugins/ubiquo_authentication/lib/ubiquo_authentication/authenticated_system.rb, line 90
90: def redirect_back_or_default(default)
91: redirect_to(session[:return_to] || default)
92: session[:return_to] = nil
93: end
Store the URI of the current request in the session.
We can return to this location by calling redirect_back_or_default.
# File vendor/plugins/ubiquo_authentication/lib/ubiquo_authentication/authenticated_system.rb, line 84
84: def store_location
85: session[:return_to] = request.request_uri
86: end
Filter method to enforce a superadmin login requirement.
To require superadmin login for all actions, use this in your controllers:
before_filter :superadmin_required
To require superadmin logins for specific actions, use this in your controllers:
before_filter :superadmin_required, :only => [ :edit, :update ]
To skip this in a subclassed controller:
skip_before_filter :superadmin_required
# File vendor/plugins/ubiquo_authentication/lib/ubiquo_authentication/authenticated_system.rb, line 57
57: def superadmin_required
58: (logged_in? && current_ubiquo_user.is_superadmin?) || access_denied
59: end
Disabled; run with $DEBUG to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.