Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Commit

Permalink
Made current_user and logged_in? be public methods. !!!! Possibly stu…
Browse files Browse the repository at this point in the history
…pid !!! I did this for the worst possible reason -- so that I could write story steps that call it directly. However, they're already globally public methods in principle through their exposure as helper methods. But if there's a less kludgy fix please educate me.
  • Loading branch information
Philip (flip) Kromer committed May 17, 2008
1 parent 6221678 commit 790f5f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG
Expand Up @@ -46,7 +46,13 @@ h3. authenticated_system
http://dev.rubyonrails.org/changeset/8987 lands.
* cookies, just like session tokens, should be refreshed each time we cross the
logged out/in barrier http://www.owasp.org/index.php/Session_Management#Regeneration_of_Session_Tokens

* !!!! Possibly stupid !!!
Made current_user and logged_in? be public methods. I did this for the worst
possible reason -- so that I could write story steps that call it directly.
However, they're already globally public methods in principle through their
exposure as helper methods. But if there's a less kludgy fix please educate
me.

h3. Changes to model

* recently_activated? belongs only if stateful
Expand Down
2 changes: 1 addition & 1 deletion generators/authenticated/templates/authenticated_system.rb
@@ -1,5 +1,4 @@
module AuthenticatedSystem
protected
# Returns true or false if the <%= file_name %> is logged in.
# Preloads @current_<%= file_name %> with the <%= file_name %> model if they're logged in.
def logged_in?
Expand All @@ -12,6 +11,7 @@ def current_<%= file_name %>
@current_<%= file_name %> ||= (login_from_session || login_from_basic_auth || login_from_cookie) unless @current_<%= file_name %> == false
end

protected
# Store the given <%= file_name %> id in the session.
def current_<%= file_name %>=(new_<%= file_name %>)
session[:<%= file_name %>_id] = new_<%= file_name %> ? new_<%= file_name %>.id : nil
Expand Down

0 comments on commit 790f5f6

Please sign in to comment.