Skip to content

Commit

Permalink
whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Cooke committed Feb 24, 2015
1 parent 8d81faf commit 43acd45
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ def change
add_index :authie_sessions, :browser_id
add_index :authie_sessions, :user_id
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ class AddParentIdToAuthieSessions < ActiveRecord::Migration
def change
add_column :authie_sessions, :parent_id, :integer
end
end
end
8 changes: 4 additions & 4 deletions lib/authie/config.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module Authie
class Config

def session_inactivity_timeout
@session_inactivity_timeout || 12.hours
end
attr_writer :session_inactivity_timeout

def persistent_session_length
@persistent_session_length || 2.months
end
attr_writer :persistent_session_length

end

def self.config
@config ||= Config.new
end
Expand Down
20 changes: 10 additions & 10 deletions lib/authie/controller_extension.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module Authie
module ControllerExtension

def self.included(base)
base.helper_method :logged_in?, :current_user, :auth_session
base.before_filter :set_browser_id, :touch_auth_session
end

private
# Set a random browser ID for this browser.

# Set a random browser ID for this browser.
def set_browser_id
until cookies[:browser_id]
proposed_browser_id = SecureRandom.uuid
Expand All @@ -17,19 +17,19 @@ def set_browser_id
end
end
end

# Touch the auth session on each request if logged in
def touch_auth_session
if logged_in?
auth_session.touch!
end
end

# Return the currently logged in user object
def current_user
auth_session.user
end

# Set the currently logged in user
def current_user=(user)
if user
Expand All @@ -42,16 +42,16 @@ def current_user=(user)
@current_user = nil
end
end

# Is anyone currently logged in?
def logged_in?
auth_session.is_a?(Session)
end

# Return the currently logged in user session
def auth_session
@auth_session ||= Session.get_session(self)
end

end
end
10 changes: 5 additions & 5 deletions lib/authie/engine.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
module Authie
class Engine < ::Rails::Engine

initializer 'authie.initialize' do |app|
config.paths["db/migrate"].expanded.each do |expanded_path|
app.config.paths["db/migrate"] << expanded_path
end

ActiveSupport.on_load :active_record do
require 'authie/session'
end

ActiveSupport.on_load :action_controller do
require 'authie/controller_extension'
include Authie::ControllerExtension
end

end

end
end
6 changes: 3 additions & 3 deletions lib/authie/rack_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# If you're dealing with your authentication in a middleware and you only have
# access to your rack environment, this will wrap around rack and make it look
# close enough to an ActionController to work with Authie
#
#
# Usage:
#
#
# controller = Authie::RackController.new(@env)
# controller.current_user = user

Expand All @@ -22,7 +22,7 @@ def cookies
@request.cookie_jar
end

# Set a random browser ID for this browser.
# Set a random browser ID for this browser.
def set_browser_id
until cookies[:browser_id]
proposed_browser_id = SecureRandom.uuid
Expand Down

0 comments on commit 43acd45

Please sign in to comment.