github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

binarylogic / authlogic

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 2,497
    • 179
  • Source
  • Commits
  • Network (179)
  • Issues (66)
  • Downloads (47)
  • Wiki (1)
  • Graphs
  • Tree: 7cd869f

click here to add a description

click here to add a homepage

  • Branches (1)
    • master
  • Tags (47)
    • v2.1.3
    • v2.1.2
    • v2.1.1
    • v2.1.0
    • v2.0.14
    • v2.0.13
    • v2.0.12
    • v2.0.11
    • v2.0.10
    • v2.0.9
    • v2.0.8
    • v2.0.7
    • v2.0.6
    • v2.0.5
    • v2.0.4
    • v2.0.3
    • v2.0.2
    • v2.0.1
    • v2.0.0RC1
    • v2.0.0
    • v1.4.3
    • v1.4.2
    • v1.4.1
    • v1.4.0
    • v1.3.9
    • v1.3.8
    • v1.3.7
    • v1.3.6
    • v1.3.5
    • v1.3.4
    • v1.3.3
    • v1.3.2
    • v1.3.1
    • v1.3.0
    • v1.2.2
    • v1.2.1
    • v1.2.0
    • v1.1.1
    • v1.1.0
    • v1.0.0
    • v0.10.4
    • v0.10.3
    • v0.10.2
    • v0.10.1
    • v0.10.0
    • v0.9.1
    • v0.9.0
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A simple model based ruby authentication solution. — Read more

  cancel

http://rdoc.info/projects/binarylogic/authlogic

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Small code cleanup Comment
binarylogic (author)
Mon Feb 16 23:45:12 -0800 2009
commit  7cd869f49a264cb7ece7e72df8ff077c06fdc5d3
tree    b55ca4db7fea3c2d6bac63a8bfaf34733c3a0899
parent  febb7c170046fa6693bf0647fd6edb488045a20d
authlogic / lib / authlogic / session / cookies.rb lib/authlogic/session/cookies.rb
100644 40 lines (36 sloc) 1.18 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module Authlogic
  module Session
    # = Cookies
    #
    # Handles all authentication that deals with cookies, such as persisting a session and saving / destroying a session.
    module Cookies
      def self.included(klass)
        klass.after_save :save_cookie, :if => :persisting?
        klass.after_destroy :destroy_cookie, :if => :persisting?
      end
      
      # Tries to validate the session from information in the cookie
      def valid_cookie?
        if cookie_credentials
          self.unauthorized_record = search_for_record("find_by_#{persistence_token_field}", cookie_credentials)
          valid?
        else
          false
        end
      end
      
      private
        def cookie_credentials
          controller.cookies[cookie_key]
        end
        
        def save_cookie
          controller.cookies[cookie_key] = {
            :value => record.send(persistence_token_field),
            :expires => remember_me_until,
            :domain => controller.cookie_domain
          }
        end
        
        def destroy_cookie
          controller.cookies.delete cookie_key, :domain => controller.cookie_domain
        end
    end
  end
end
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server