Skip to content

Commit

Permalink
Added support for subdomains.
Browse files Browse the repository at this point in the history
  • Loading branch information
garymardell committed May 16, 2013
1 parent e0112ea commit 26406b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/clearance/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ def current_user=(user)
clearance_session.sign_in user
end

def sign_in(user)
clearance_session.sign_in user
def sign_in(user, domain = nil)
domain ||= request.host
clearance_session.sign_in user, domain
end

def sign_out
Expand Down
10 changes: 8 additions & 2 deletions lib/clearance/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def add_cookie_to_headers(headers)
:value => current_user.remember_token,
:expires => Clearance.configuration.cookie_expiration.call,
:secure => Clearance.configuration.secure_cookie,
:path => '/'
:path => '/',
:domain => current_domain
)
end
end
Expand All @@ -23,9 +24,14 @@ def current_user
Clearance.configuration.user_model.find_by_remember_token token
end
end

def current_domain
@current_domain || @env['SERVER_NAME']
end

def sign_in(user)
def sign_in(user, domain = nil)
@current_user = user
@current_domain = domain
end

def sign_out
Expand Down

0 comments on commit 26406b6

Please sign in to comment.