Empact-authlogic 2.1.5 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Empact-authlogic.gemspec +190 -187
- data/Gemfile +10 -0
- data/Gemfile.lock +49 -0
- data/LICENSE +1 -1
- data/README.rdoc +14 -10
- data/Rakefile +5 -5
- data/VERSION.yml +3 -3
- data/lib/authlogic/acts_as_authentic/base.rb +14 -12
- data/lib/authlogic/acts_as_authentic/email.rb +12 -12
- data/lib/authlogic/acts_as_authentic/logged_in_status.rb +8 -9
- data/lib/authlogic/acts_as_authentic/login.rb +19 -18
- data/lib/authlogic/acts_as_authentic/password.rb +3 -3
- data/lib/authlogic/acts_as_authentic/perishable_token.rb +15 -15
- data/lib/authlogic/acts_as_authentic/persistence_token.rb +1 -1
- data/lib/authlogic/authenticates_many/base.rb +3 -4
- data/lib/authlogic/controller_adapters/rails_adapter.rb +1 -1
- data/lib/authlogic/random.rb +1 -1
- data/lib/authlogic/session/active_record_trickery.rb +8 -0
- data/lib/authlogic/session/callbacks.rb +2 -2
- data/lib/authlogic/session/cookies.rb +54 -2
- data/lib/authlogic/session/foundation.rb +17 -3
- data/lib/authlogic/session/http_auth.rb +43 -2
- data/lib/authlogic/session/scopes.rb +9 -9
- data/lib/authlogic/test_case/mock_controller.rb +12 -2
- data/lib/generators/authlogic/USAGE +8 -0
- data/lib/generators/authlogic/session_generator.rb +14 -0
- data/lib/generators/authlogic/templates/session.rb +2 -0
- data/test/acts_as_authentic_test/base_test.rb +1 -1
- data/test/acts_as_authentic_test/email_test.rb +29 -21
- data/test/acts_as_authentic_test/logged_in_status_test.rb +1 -1
- data/test/acts_as_authentic_test/login_test.rb +1 -1
- data/test/acts_as_authentic_test/magic_columns_test.rb +1 -1
- data/test/acts_as_authentic_test/password_test.rb +1 -1
- data/test/acts_as_authentic_test/perishable_token_test.rb +1 -1
- data/test/acts_as_authentic_test/persistence_token_test.rb +1 -1
- data/test/acts_as_authentic_test/restful_authentication_test.rb +1 -1
- data/test/acts_as_authentic_test/session_maintenance_test.rb +1 -1
- data/test/acts_as_authentic_test/single_access_test.rb +1 -1
- data/test/authenticates_many_test.rb +1 -1
- data/test/crypto_provider_test/aes256_test.rb +1 -1
- data/test/crypto_provider_test/bcrypt_test.rb +1 -1
- data/test/crypto_provider_test/sha1_test.rb +1 -1
- data/test/crypto_provider_test/sha256_test.rb +1 -1
- data/test/crypto_provider_test/sha512_test.rb +1 -1
- data/test/i18n_test.rb +1 -1
- data/test/random_test.rb +1 -8
- data/test/session_test/activation_test.rb +1 -1
- data/test/session_test/active_record_trickery_test.rb +12 -2
- data/test/session_test/brute_force_protection_test.rb +1 -1
- data/test/session_test/callbacks_test.rb +1 -1
- data/test/session_test/cookies_test.rb +26 -2
- data/test/session_test/existence_test.rb +1 -1
- data/test/session_test/http_auth_test.rb +31 -3
- data/test/session_test/id_test.rb +1 -1
- data/test/session_test/klass_test.rb +1 -1
- data/test/session_test/magic_columns_test.rb +1 -1
- data/test/session_test/magic_states_test.rb +1 -1
- data/test/session_test/params_test.rb +1 -1
- data/test/session_test/password_test.rb +1 -1
- data/test/session_test/perishability_test.rb +1 -1
- data/test/session_test/persistence_test.rb +1 -1
- data/test/session_test/scopes_test.rb +12 -12
- data/test/session_test/session_test.rb +1 -1
- data/test/session_test/timeout_test.rb +1 -1
- data/test/session_test/unauthorized_record_test.rb +1 -1
- data/test/session_test/validation_test.rb +1 -1
- data/test/test_helper.rb +27 -41
- metadata +50 -55
- data/.gitignore +0 -9
- data/CHANGELOG.rdoc +0 -353
    
        data/LICENSE
    CHANGED
    
    
    
        data/README.rdoc
    CHANGED
    
    | @@ -1,5 +1,7 @@ | |
| 1 1 | 
             
            = Authlogic
         | 
| 2 2 |  | 
| 3 | 
            +
            ** Please note the latest version is compatible with rails 3 only. Rails 2 should use version 2.X.X **
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
            Authlogic is a clean, simple, and unobtrusive ruby authentication solution.
         | 
| 4 6 |  | 
| 5 7 | 
             
            A code example can replace a thousand words...
         | 
| @@ -67,8 +69,12 @@ If you find a bug or a problem please post it in the issues section. If you need | |
| 67 69 | 
             
            * <b>Authlogic OpenID addon:</b> http://github.com/binarylogic/authlogic_openid
         | 
| 68 70 | 
             
            * <b>Authlogic LDAP addon:</b> http://github.com/binarylogic/authlogic_ldap
         | 
| 69 71 | 
             
            * <b>Authlogic Facebook Connect:</b> http://github.com/kalasjocke/authlogic_facebook_connect
         | 
| 72 | 
            +
            * <b>Authlogic Facebook Connect (New JS API):</b> http://github.com/studybyte/authlogic_facebook_connect
         | 
| 73 | 
            +
            * <b>Authlogic Facebook Shim</b> http://github.com/james2m/authlogic_facebook_shim
         | 
| 70 74 | 
             
            * <b>Authlogic OAuth (Twitter):</b> http://github.com/jrallison/authlogic_oauth
         | 
| 75 | 
            +
            * <b>Authlogic Oauth and OpenID:</b> http://github.com/viatropos/authlogic-connect
         | 
| 71 76 | 
             
            * <b>Authlogic PAM:</b> http://github.com/nbudin/authlogic_pam
         | 
| 77 | 
            +
            * <b>Authlogic x509:</b> http://github.com/auth-scc/authlogic_x509
         | 
| 72 78 |  | 
| 73 79 | 
             
            If you create one of your own, please let me know about it so I can add it to this list. Or just fork the project, add your link, and send me a pull request.
         | 
| 74 80 |  | 
| @@ -150,7 +156,7 @@ What if your user sessions controller could look just like your other controller | |
| 150 156 | 
             
                def new
         | 
| 151 157 | 
             
                  @user_session = UserSession.new
         | 
| 152 158 | 
             
                end
         | 
| 153 | 
            -
             | 
| 159 | 
            +
             | 
| 154 160 | 
             
                def create
         | 
| 155 161 | 
             
                  @user_session = UserSession.new(params[:user_session])
         | 
| 156 162 | 
             
                  if @user_session.save
         | 
| @@ -159,7 +165,7 @@ What if your user sessions controller could look just like your other controller | |
| 159 165 | 
             
                    render :action => :new
         | 
| 160 166 | 
             
                  end
         | 
| 161 167 | 
             
                end
         | 
| 162 | 
            -
             | 
| 168 | 
            +
             | 
| 163 169 | 
             
                def destroy
         | 
| 164 170 | 
             
                  current_user_session.destroy
         | 
| 165 171 | 
             
                  redirect_to new_user_session_url
         | 
| @@ -183,13 +189,13 @@ Or how about persisting the session... | |
| 183 189 |  | 
| 184 190 | 
             
              class ApplicationController
         | 
| 185 191 | 
             
                helper_method :current_user_session, :current_user
         | 
| 186 | 
            -
             | 
| 192 | 
            +
             | 
| 187 193 | 
             
                private
         | 
| 188 194 | 
             
                  def current_user_session
         | 
| 189 195 | 
             
                    return @current_user_session if defined?(@current_user_session)
         | 
| 190 196 | 
             
                    @current_user_session = UserSession.find
         | 
| 191 197 | 
             
                  end
         | 
| 192 | 
            -
             | 
| 198 | 
            +
             | 
| 193 199 | 
             
                  def current_user
         | 
| 194 200 | 
             
                    return @current_user if defined?(@current_user)
         | 
| 195 201 | 
             
                    @current_user = current_user_session && current_user_session.user
         | 
| @@ -200,17 +206,15 @@ Or how about persisting the session... | |
| 200 206 |  | 
| 201 207 | 
             
            Install the gem / plugin (recommended)
         | 
| 202 208 |  | 
| 203 | 
            -
             | 
| 209 | 
            +
            Rails 3:
         | 
| 204 210 |  | 
| 205 211 | 
             
              $ sudo gem install authlogic
         | 
| 206 212 |  | 
| 207 | 
            -
             | 
| 208 | 
            -
             | 
| 209 | 
            -
              $ sudo gem install binarylogic-authlogic
         | 
| 213 | 
            +
            Rails 2:
         | 
| 210 214 |  | 
| 211 | 
            -
             | 
| 215 | 
            +
              $ sudo gem install authlogic --version=2.1.6
         | 
| 212 216 |  | 
| 213 | 
            -
            Or  | 
| 217 | 
            +
            Or install as a plugin:
         | 
| 214 218 |  | 
| 215 219 | 
             
              script/plugin install git://github.com/binarylogic/authlogic.git
         | 
| 216 220 |  | 
    
        data/Rakefile
    CHANGED
    
    | @@ -1,5 +1,8 @@ | |
| 1 1 | 
             
            require 'rubygems'
         | 
| 2 2 | 
             
            require 'rake'
         | 
| 3 | 
            +
            require 'bundler'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Bundler.setup
         | 
| 3 6 |  | 
| 4 7 | 
             
            begin
         | 
| 5 8 | 
             
              require 'jeweler'
         | 
| @@ -9,10 +12,9 @@ begin | |
| 9 12 | 
             
                gem.email = "bjohnson@binarylogic.com"
         | 
| 10 13 | 
             
                gem.homepage = "http://github.com/binarylogic/authlogic"
         | 
| 11 14 | 
             
                gem.authors = ["Ben Johnson of Binary Logic", "Ben Woosley"]
         | 
| 12 | 
            -
                gem. | 
| 13 | 
            -
                gem.add_dependency "activesupport"
         | 
| 15 | 
            +
                gem.add_bundler_dependencies
         | 
| 14 16 | 
             
              end
         | 
| 15 | 
            -
              Jeweler:: | 
| 17 | 
            +
              Jeweler::GemcutterTasks.new
         | 
| 16 18 | 
             
            rescue LoadError
         | 
| 17 19 | 
             
              puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
         | 
| 18 20 | 
             
            end
         | 
| @@ -37,6 +39,4 @@ rescue LoadError | |
| 37 39 | 
             
              end
         | 
| 38 40 | 
             
            end
         | 
| 39 41 |  | 
| 40 | 
            -
            task :test => :check_dependencies
         | 
| 41 | 
            -
             | 
| 42 42 | 
             
            task :default => :test
         | 
    
        data/VERSION.yml
    CHANGED
    
    
| @@ -4,6 +4,9 @@ module Authlogic | |
| 4 4 | 
             
                module Base
         | 
| 5 5 | 
             
                  def self.included(klass)
         | 
| 6 6 | 
             
                    klass.class_eval do
         | 
| 7 | 
            +
                      class_attribute :acts_as_authentic_modules, :acts_as_authentic_config
         | 
| 8 | 
            +
                      self.acts_as_authentic_modules ||= []
         | 
| 9 | 
            +
                      self.acts_as_authentic_config  ||= {}
         | 
| 7 10 | 
             
                      extend Config
         | 
| 8 11 | 
             
                    end
         | 
| 9 12 | 
             
                  end
         | 
| @@ -41,7 +44,7 @@ module Authlogic | |
| 41 44 | 
             
                    #
         | 
| 42 45 | 
             
                    # That being said, this is your tool for extending Authlogic and "hooking" into the acts_as_authentic call.
         | 
| 43 46 | 
             
                    def add_acts_as_authentic_module(mod, action = :append)
         | 
| 44 | 
            -
                      modules = acts_as_authentic_modules
         | 
| 47 | 
            +
                      modules = acts_as_authentic_modules.clone
         | 
| 45 48 | 
             
                      case action
         | 
| 46 49 | 
             
                      when :append
         | 
| 47 50 | 
             
                        modules << mod
         | 
| @@ -49,21 +52,17 @@ module Authlogic | |
| 49 52 | 
             
                        modules = [mod] + modules
         | 
| 50 53 | 
             
                      end
         | 
| 51 54 | 
             
                      modules.uniq!
         | 
| 52 | 
            -
                       | 
| 55 | 
            +
                      self.acts_as_authentic_modules = modules
         | 
| 53 56 | 
             
                    end
         | 
| 54 57 |  | 
| 55 58 | 
             
                    # This is the same as add_acts_as_authentic_module, except that it removes the module from the list.
         | 
| 56 59 | 
             
                    def remove_acts_as_authentic_module(mod)
         | 
| 57 | 
            -
                      acts_as_authentic_modules. | 
| 58 | 
            -
                       | 
| 60 | 
            +
                      modules = acts_as_authentic_modules.clone
         | 
| 61 | 
            +
                      modules.delete(mod)
         | 
| 62 | 
            +
                      self.acts_as_authentic_modules = modules
         | 
| 59 63 | 
             
                    end
         | 
| 60 | 
            -
             | 
| 64 | 
            +
             | 
| 61 65 | 
             
                    private
         | 
| 62 | 
            -
                      def acts_as_authentic_modules
         | 
| 63 | 
            -
                        key = :acts_as_authentic_modules
         | 
| 64 | 
            -
                        inheritable_attributes.include?(key) ? read_inheritable_attribute(key) : []
         | 
| 65 | 
            -
                      end
         | 
| 66 | 
            -
                      
         | 
| 67 66 | 
             
                      def db_setup?
         | 
| 68 67 | 
             
                        begin
         | 
| 69 68 | 
             
                          column_names
         | 
| @@ -75,9 +74,12 @@ module Authlogic | |
| 75 74 |  | 
| 76 75 | 
             
                      def rw_config(key, value, default_value = nil, read_value = nil)
         | 
| 77 76 | 
             
                        if value == read_value
         | 
| 78 | 
            -
                           | 
| 77 | 
            +
                          acts_as_authentic_config.include?(key) ? acts_as_authentic_config[key] : default_value
         | 
| 79 78 | 
             
                        else
         | 
| 80 | 
            -
                           | 
| 79 | 
            +
                          config = acts_as_authentic_config.clone
         | 
| 80 | 
            +
                          config[key] = value
         | 
| 81 | 
            +
                          self.acts_as_authentic_config = config
         | 
| 82 | 
            +
                          value
         | 
| 81 83 | 
             
                        end
         | 
| 82 84 | 
             
                      end
         | 
| 83 85 |  | 
| @@ -11,7 +11,7 @@ module Authlogic | |
| 11 11 | 
             
                      add_acts_as_authentic_module(Methods)
         | 
| 12 12 | 
             
                    end
         | 
| 13 13 | 
             
                  end
         | 
| 14 | 
            -
             | 
| 14 | 
            +
             | 
| 15 15 | 
             
                  # Configuration to modify how Authlogic handles the email field.
         | 
| 16 16 | 
             
                  module Config
         | 
| 17 17 | 
             
                    # The name of the field that stores email addresses.
         | 
| @@ -22,7 +22,7 @@ module Authlogic | |
| 22 22 | 
             
                      rw_config(:email_field, value, first_column_to_exist(nil, :email, :email_address))
         | 
| 23 23 | 
             
                    end
         | 
| 24 24 | 
             
                    alias_method :email_field=, :email_field
         | 
| 25 | 
            -
             | 
| 25 | 
            +
             | 
| 26 26 | 
             
                    # Toggles validating the email field or not.
         | 
| 27 27 | 
             
                    #
         | 
| 28 28 | 
             
                    # * <tt>Default:</tt> true
         | 
| @@ -31,20 +31,20 @@ module Authlogic | |
| 31 31 | 
             
                      rw_config(:validate_email_field, value, true)
         | 
| 32 32 | 
             
                    end
         | 
| 33 33 | 
             
                    alias_method :validate_email_field=, :validate_email_field
         | 
| 34 | 
            -
             | 
| 34 | 
            +
             | 
| 35 35 | 
             
                    # A hash of options for the validates_length_of call for the email field. Allows you to change this however you want.
         | 
| 36 36 | 
             
                    #
         | 
| 37 37 | 
             
                    # <b>Keep in mind this is ruby. I wanted to keep this as flexible as possible, so you can completely replace the hash or
         | 
| 38 38 | 
             
                    # merge options into it. Checkout the convenience function merge_validates_length_of_email_field_options to merge
         | 
| 39 39 | 
             
                    # options.</b>
         | 
| 40 40 | 
             
                    #
         | 
| 41 | 
            -
                    # * <tt>Default:</tt> {: | 
| 41 | 
            +
                    # * <tt>Default:</tt> {:maximum => 100}
         | 
| 42 42 | 
             
                    # * <tt>Accepts:</tt> Hash of options accepted by validates_length_of
         | 
| 43 43 | 
             
                    def validates_length_of_email_field_options(value = nil)
         | 
| 44 | 
            -
                      rw_config(:validates_length_of_email_field_options, value, {: | 
| 44 | 
            +
                      rw_config(:validates_length_of_email_field_options, value, {:maximum => 100})
         | 
| 45 45 | 
             
                    end
         | 
| 46 46 | 
             
                    alias_method :validates_length_of_email_field_options=, :validates_length_of_email_field_options
         | 
| 47 | 
            -
             | 
| 47 | 
            +
             | 
| 48 48 | 
             
                    # A convenience function to merge options into the validates_length_of_email_field_options. So intead of:
         | 
| 49 49 | 
             
                    #
         | 
| 50 50 | 
             
                    #   self.validates_length_of_email_field_options = validates_length_of_email_field_options.merge(:my_option => my_value)
         | 
| @@ -55,25 +55,25 @@ module Authlogic | |
| 55 55 | 
             
                    def merge_validates_length_of_email_field_options(options = {})
         | 
| 56 56 | 
             
                      self.validates_length_of_email_field_options = validates_length_of_email_field_options.merge(options)
         | 
| 57 57 | 
             
                    end
         | 
| 58 | 
            -
             | 
| 58 | 
            +
             | 
| 59 59 | 
             
                    # A hash of options for the validates_format_of call for the email field. Allows you to change this however you want.
         | 
| 60 60 | 
             
                    #
         | 
| 61 61 | 
             
                    # <b>Keep in mind this is ruby. I wanted to keep this as flexible as possible, so you can completely replace the hash or
         | 
| 62 62 | 
             
                    # merge options into it. Checkout the convenience function merge_validates_format_of_email_field_options to merge
         | 
| 63 63 | 
             
                    # options.</b>
         | 
| 64 64 | 
             
                    #
         | 
| 65 | 
            -
                    # * <tt>Default:</tt> {:with => Authlogic::Regex.email, :message => I18n.t('error_messages.email_invalid', :default => "should look like an email address.")}
         | 
| 65 | 
            +
                    # * <tt>Default:</tt> {:with => Authlogic::Regex.email, :message => lambda {I18n.t('error_messages.email_invalid', :default => "should look like an email address.")}}
         | 
| 66 66 | 
             
                    # * <tt>Accepts:</tt> Hash of options accepted by validates_format_of
         | 
| 67 67 | 
             
                    def validates_format_of_email_field_options(value = nil)
         | 
| 68 68 | 
             
                      rw_config(:validates_format_of_email_field_options, value, {:with => Authlogic::Regex.email, :message => I18n.t('error_messages.email_invalid', :default => "should look like an email address.")})
         | 
| 69 69 | 
             
                    end
         | 
| 70 70 | 
             
                    alias_method :validates_format_of_email_field_options=, :validates_format_of_email_field_options
         | 
| 71 | 
            -
             | 
| 71 | 
            +
             | 
| 72 72 | 
             
                    # See merge_validates_length_of_email_field_options. The same thing except for validates_format_of_email_field_options.
         | 
| 73 73 | 
             
                    def merge_validates_format_of_email_field_options(options = {})
         | 
| 74 74 | 
             
                      self.validates_format_of_email_field_options = validates_format_of_email_field_options.merge(options)
         | 
| 75 75 | 
             
                    end
         | 
| 76 | 
            -
             | 
| 76 | 
            +
             | 
| 77 77 | 
             
                    # A hash of options for the validates_uniqueness_of call for the email field. Allows you to change this however you want.
         | 
| 78 78 | 
             
                    #
         | 
| 79 79 | 
             
                    # <b>Keep in mind this is ruby. I wanted to keep this as flexible as possible, so you can completely replace the hash or
         | 
| @@ -86,13 +86,13 @@ module Authlogic | |
| 86 86 | 
             
                      rw_config(:validates_uniqueness_of_email_field_options, value, {:case_sensitive => false, :scope => validations_scope, :if => "#{email_field}_changed?".to_sym})
         | 
| 87 87 | 
             
                    end
         | 
| 88 88 | 
             
                    alias_method :validates_uniqueness_of_email_field_options=, :validates_uniqueness_of_email_field_options
         | 
| 89 | 
            -
             | 
| 89 | 
            +
             | 
| 90 90 | 
             
                    # See merge_validates_length_of_email_field_options. The same thing except for validates_uniqueness_of_email_field_options.
         | 
| 91 91 | 
             
                    def merge_validates_uniqueness_of_email_field_options(options = {})
         | 
| 92 92 | 
             
                      self.validates_uniqueness_of_email_field_options = validates_uniqueness_of_email_field_options.merge(options)
         | 
| 93 93 | 
             
                    end
         | 
| 94 94 | 
             
                  end
         | 
| 95 | 
            -
             | 
| 95 | 
            +
             | 
| 96 96 | 
             
                  # All methods relating to the email field
         | 
| 97 97 | 
             
                  module Methods
         | 
| 98 98 | 
             
                    def self.included(klass)
         | 
| @@ -11,7 +11,7 @@ module Authlogic | |
| 11 11 | 
             
                      add_acts_as_authentic_module(Methods)
         | 
| 12 12 | 
             
                    end
         | 
| 13 13 | 
             
                  end
         | 
| 14 | 
            -
             | 
| 14 | 
            +
             | 
| 15 15 | 
             
                  # All configuration for the logged in status feature set.
         | 
| 16 16 | 
             
                  module Config
         | 
| 17 17 | 
             
                    # The timeout to determine when a user is logged in or not.
         | 
| @@ -23,32 +23,31 @@ module Authlogic | |
| 23 23 | 
             
                    end
         | 
| 24 24 | 
             
                    alias_method :logged_in_timeout=, :logged_in_timeout
         | 
| 25 25 | 
             
                  end
         | 
| 26 | 
            -
             | 
| 26 | 
            +
             | 
| 27 27 | 
             
                  # All methods for the logged in status feature seat.
         | 
| 28 28 | 
             
                  module Methods
         | 
| 29 29 | 
             
                    def self.included(klass)
         | 
| 30 30 | 
             
                      return if !klass.column_names.include?("last_request_at")
         | 
| 31 | 
            -
             | 
| 31 | 
            +
             | 
| 32 32 | 
             
                      klass.class_eval do
         | 
| 33 33 | 
             
                        include InstanceMethods
         | 
| 34 | 
            -
                        
         | 
| 35 | 
            -
                         | 
| 36 | 
            -
                        named_scope :logged_out, lambda { {:conditions => ["last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago]} }
         | 
| 34 | 
            +
                        scope :logged_in, where("last_request_at > ?", logged_in_timeout.seconds.ago)
         | 
| 35 | 
            +
                        scope :logged_out, where("last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago)
         | 
| 37 36 | 
             
                      end
         | 
| 38 37 | 
             
                    end
         | 
| 39 | 
            -
             | 
| 38 | 
            +
             | 
| 40 39 | 
             
                    module InstanceMethods
         | 
| 41 40 | 
             
                      # Returns true if the last_request_at > logged_in_timeout.
         | 
| 42 41 | 
             
                      def logged_in?
         | 
| 43 42 | 
             
                        raise "Can not determine the records login state because there is no last_request_at column" if !respond_to?(:last_request_at)
         | 
| 44 43 | 
             
                        !last_request_at.nil? && last_request_at > logged_in_timeout.seconds.ago
         | 
| 45 44 | 
             
                      end
         | 
| 46 | 
            -
             | 
| 45 | 
            +
             | 
| 47 46 | 
             
                      # Opposite of logged_in?
         | 
| 48 47 | 
             
                      def logged_out?
         | 
| 49 48 | 
             
                        !logged_in?
         | 
| 50 49 | 
             
                      end
         | 
| 51 | 
            -
             | 
| 50 | 
            +
             | 
| 52 51 | 
             
                      private
         | 
| 53 52 | 
             
                        def logged_in_timeout
         | 
| 54 53 | 
             
                          self.class.logged_in_timeout
         | 
| @@ -8,8 +8,8 @@ module Authlogic | |
| 8 8 | 
             
                      add_acts_as_authentic_module(Methods)
         | 
| 9 9 | 
             
                    end
         | 
| 10 10 | 
             
                  end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                  #  | 
| 11 | 
            +
             | 
| 12 | 
            +
                  # Configuration for the login field.
         | 
| 13 13 | 
             
                  module Config
         | 
| 14 14 | 
             
                    # The name of the login field in the database.
         | 
| 15 15 | 
             
                    #
         | 
| @@ -19,8 +19,8 @@ module Authlogic | |
| 19 19 | 
             
                      rw_config(:login_field, value, first_column_to_exist(nil, :login, :username))
         | 
| 20 20 | 
             
                    end
         | 
| 21 21 | 
             
                    alias_method :login_field=, :login_field
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                    # Whether or not  | 
| 22 | 
            +
             | 
| 23 | 
            +
                    # Whether or not to validate the login field
         | 
| 24 24 | 
             
                    #
         | 
| 25 25 | 
             
                    # * <tt>Default:</tt> true
         | 
| 26 26 | 
             
                    # * <tt>Accepts:</tt> Boolean
         | 
| @@ -28,7 +28,7 @@ module Authlogic | |
| 28 28 | 
             
                      rw_config(:validate_login_field, value, true)
         | 
| 29 29 | 
             
                    end
         | 
| 30 30 | 
             
                    alias_method :validate_login_field=, :validate_login_field
         | 
| 31 | 
            -
             | 
| 31 | 
            +
             | 
| 32 32 | 
             
                    # A hash of options for the validates_length_of call for the login field. Allows you to change this however you want.
         | 
| 33 33 | 
             
                    #
         | 
| 34 34 | 
             
                    # <b>Keep in mind this is ruby. I wanted to keep this as flexible as possible, so you can completely replace the hash or
         | 
| @@ -41,8 +41,8 @@ module Authlogic | |
| 41 41 | 
             
                      rw_config(:validates_length_of_login_field_options, value, {:within => 3..100})
         | 
| 42 42 | 
             
                    end
         | 
| 43 43 | 
             
                    alias_method :validates_length_of_login_field_options=, :validates_length_of_login_field_options
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                    # A convenience function to merge options into the validates_length_of_login_field_options. So  | 
| 44 | 
            +
             | 
| 45 | 
            +
                    # A convenience function to merge options into the validates_length_of_login_field_options. So instead of:
         | 
| 46 46 | 
             
                    #
         | 
| 47 47 | 
             
                    #   self.validates_length_of_login_field_options = validates_length_of_login_field_options.merge(:my_option => my_value)
         | 
| 48 48 | 
             
                    #
         | 
| @@ -52,25 +52,25 @@ module Authlogic | |
| 52 52 | 
             
                    def merge_validates_length_of_login_field_options(options = {})
         | 
| 53 53 | 
             
                      self.validates_length_of_login_field_options = validates_length_of_login_field_options.merge(options)
         | 
| 54 54 | 
             
                    end
         | 
| 55 | 
            -
             | 
| 55 | 
            +
             | 
| 56 56 | 
             
                    # A hash of options for the validates_format_of call for the login field. Allows you to change this however you want.
         | 
| 57 57 | 
             
                    #
         | 
| 58 58 | 
             
                    # <b>Keep in mind this is ruby. I wanted to keep this as flexible as possible, so you can completely replace the hash or
         | 
| 59 59 | 
             
                    # merge options into it. Checkout the convenience function merge_validates_format_of_login_field_options to merge
         | 
| 60 60 | 
             
                    # options.</b>
         | 
| 61 61 | 
             
                    #
         | 
| 62 | 
            -
                    # * <tt>Default:</tt> {:with => Authlogic::Regex.login, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}
         | 
| 62 | 
            +
                    # * <tt>Default:</tt> {:with => Authlogic::Regex.login, :message => lambda {I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")}}
         | 
| 63 63 | 
             
                    # * <tt>Accepts:</tt> Hash of options accepted by validates_format_of
         | 
| 64 64 | 
             
                    def validates_format_of_login_field_options(value = nil)
         | 
| 65 65 | 
             
                      rw_config(:validates_format_of_login_field_options, value, {:with => Authlogic::Regex.login, :message => I18n.t('error_messages.login_invalid', :default => "should use only letters, numbers, spaces, and .-_@ please.")})
         | 
| 66 66 | 
             
                    end
         | 
| 67 67 | 
             
                    alias_method :validates_format_of_login_field_options=, :validates_format_of_login_field_options
         | 
| 68 | 
            -
             | 
| 68 | 
            +
             | 
| 69 69 | 
             
                    # See merge_validates_length_of_login_field_options. The same thing, except for validates_format_of_login_field_options
         | 
| 70 70 | 
             
                    def merge_validates_format_of_login_field_options(options = {})
         | 
| 71 71 | 
             
                      self.validates_format_of_login_field_options = validates_format_of_login_field_options.merge(options)
         | 
| 72 72 | 
             
                    end
         | 
| 73 | 
            -
             | 
| 73 | 
            +
             | 
| 74 74 | 
             
                    # A hash of options for the validates_uniqueness_of call for the login field. Allows you to change this however you want.
         | 
| 75 75 | 
             
                    #
         | 
| 76 76 | 
             
                    # <b>Keep in mind this is ruby. I wanted to keep this as flexible as possible, so you can completely replace the hash or
         | 
| @@ -83,18 +83,18 @@ module Authlogic | |
| 83 83 | 
             
                      rw_config(:validates_uniqueness_of_login_field_options, value, {:case_sensitive => false, :scope => validations_scope, :if => "#{login_field}_changed?".to_sym})
         | 
| 84 84 | 
             
                    end
         | 
| 85 85 | 
             
                    alias_method :validates_uniqueness_of_login_field_options=, :validates_uniqueness_of_login_field_options
         | 
| 86 | 
            -
             | 
| 86 | 
            +
             | 
| 87 87 | 
             
                    # See merge_validates_length_of_login_field_options. The same thing, except for validates_uniqueness_of_login_field_options
         | 
| 88 88 | 
             
                    def merge_validates_uniqueness_of_login_field_options(options = {})
         | 
| 89 89 | 
             
                      self.validates_uniqueness_of_login_field_options = validates_uniqueness_of_login_field_options.merge(options)
         | 
| 90 90 | 
             
                    end
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                    # This method allows you to find a record with the given login. If you notice, with  | 
| 91 | 
            +
             | 
| 92 | 
            +
                    # This method allows you to find a record with the given login. If you notice, with Active Record you have the
         | 
| 93 93 | 
             
                    # validates_uniqueness_of validation function. They give you a :case_sensitive option. I handle this in the same
         | 
| 94 94 | 
             
                    # manner that they handle that. If you are using the login field and set false for the :case_sensitive option in
         | 
| 95 95 | 
             
                    # validates_uniqueness_of_login_field_options this method will modify the query to look something like:
         | 
| 96 96 | 
             
                    #
         | 
| 97 | 
            -
                    #    | 
| 97 | 
            +
                    #   where("LOWER(#{quoted_table_name}.#{login_field}) = ?", login.downcase).first
         | 
| 98 98 | 
             
                    #
         | 
| 99 99 | 
             
                    # If you don't specify this it calls the good old find_by_* method:
         | 
| 100 100 | 
             
                    #
         | 
| @@ -112,17 +112,18 @@ module Authlogic | |
| 112 112 | 
             
                        find_with_case(email_field, login, validates_uniqueness_of_email_field_options[:case_sensitive] != false)
         | 
| 113 113 | 
             
                      end
         | 
| 114 114 | 
             
                    end
         | 
| 115 | 
            -
             | 
| 115 | 
            +
             | 
| 116 116 | 
             
                    private
         | 
| 117 117 | 
             
                      def find_with_case(field, value, sensitivity = true)
         | 
| 118 118 | 
             
                        if sensitivity
         | 
| 119 119 | 
             
                          send("find_by_#{field}", value)
         | 
| 120 120 | 
             
                        else
         | 
| 121 | 
            -
                           | 
| 121 | 
            +
                          like_word = ::ActiveRecord::Base.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE"
         | 
| 122 | 
            +
                          where("#{quoted_table_name}.#{field} #{like_word} ?", value.mb_chars).first
         | 
| 122 123 | 
             
                        end
         | 
| 123 124 | 
             
                      end
         | 
| 124 125 | 
             
                  end
         | 
| 125 | 
            -
             | 
| 126 | 
            +
             | 
| 126 127 | 
             
                  # All methods relating to the login field
         | 
| 127 128 | 
             
                  module Methods
         | 
| 128 129 | 
             
                    # Adds in various validations, modules, etc.
         | 
| @@ -182,7 +182,7 @@ module Authlogic | |
| 182 182 | 
             
                      klass.define_callbacks *METHODS
         | 
| 183 183 |  | 
| 184 184 | 
             
                      # If Rails 3, support the new callback syntax
         | 
| 185 | 
            -
                      if klass.singleton_class.method_defined?(:set_callback)
         | 
| 185 | 
            +
                      if klass.send(klass.respond_to?(:singleton_class) ? :singleton_class : :metaclass).method_defined?(:set_callback)
         | 
| 186 186 | 
             
                        METHODS.each do |method|
         | 
| 187 187 | 
             
                          klass.class_eval <<-"end_eval", __FILE__, __LINE__
         | 
| 188 188 | 
             
                            def self.#{method}(*methods, &block)
         | 
| @@ -277,7 +277,7 @@ module Authlogic | |
| 277 277 | 
             
                      # Resets the password to a random friendly token and then saves the record.
         | 
| 278 278 | 
             
                      def reset_password!
         | 
| 279 279 | 
             
                        reset_password
         | 
| 280 | 
            -
                        save_without_session_maintenance(false)
         | 
| 280 | 
            +
                        save_without_session_maintenance(:validate => false)
         | 
| 281 281 | 
             
                      end
         | 
| 282 282 | 
             
                      alias_method :randomize_password!, :reset_password!
         | 
| 283 283 |  | 
| @@ -314,7 +314,7 @@ module Authlogic | |
| 314 314 |  | 
| 315 315 | 
             
                        def transition_password(attempted_password)
         | 
| 316 316 | 
             
                          self.password = attempted_password
         | 
| 317 | 
            -
                          save(false)
         | 
| 317 | 
            +
                          save(:validate => false)
         | 
| 318 318 | 
             
                        end
         | 
| 319 319 |  | 
| 320 320 | 
             
                        def require_password?
         |