Sha256: 101018ceafaffffba429928997b28169eb24892618759ff2603c44e814094b2f

Contents?: true

Size: 1.09 KB

Versions: 24

Compression:

Stored size: 1.09 KB

Contents

module Challah
  module UserPasswordable
    # Set the password and password_confirmation in one shortcut method.
    def password!(new_password)
      self.password = new_password
      self.password_confirmation = new_password
    end

    def password_provider?
      return true if @password_updated or @username_updated
      !!providers[:password]
    end

    def password_provider
      providers[:password] || Hash.new
    end

    # Set a password for this user
    def password=(value)
      if value.to_s.blank?
        @password = nil
        @password_updated = false
      else
        @password = value
        @password_updated = true
      end
    end

    # Set the confirmation when changing a password
    def password_confirmation=(value)
      @password_confirmation = value
    end

    # Was the password updated
    def password_changed?
      !!@password
    end

    def username
      @username ||= password_provider? ? password_provider.fetch(:uid, '') : ''
    end

    def username=(value)
      @username_updated = true
      @username = value.to_s.strip.downcase
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
challah-1.6.1 lib/challah/concerns/user/passwordable.rb
challah-1.6.0 lib/challah/concerns/user/passwordable.rb
challah-1.5.0 lib/challah/concerns/user/passwordable.rb
challah-1.4.2 lib/challah/concerns/user/passwordable.rb
challah-1.4.1 lib/challah/concerns/user/passwordable.rb
challah-1.4.0 lib/challah/concerns/user/passwordable.rb
challah-1.3.3 lib/challah/concerns/user/passwordable.rb
challah-1.3.2 lib/challah/concerns/user/passwordable.rb
challah-1.3.1 lib/challah/concerns/user/passwordable.rb
challah-1.3.0 lib/challah/concerns/user/passwordable.rb
challah-1.2.11 lib/challah/concerns/user/passwordable.rb
challah-1.2.10 lib/challah/concerns/user/passwordable.rb
challah-1.2.9 lib/challah/concerns/user/passwordable.rb
challah-1.2.8 lib/challah/concerns/user/passwordable.rb
challah-1.2.7 lib/challah/concerns/user/passwordable.rb
challah-1.2.6 lib/challah/concerns/user/passwordable.rb
challah-1.2.5 lib/challah/concerns/user/passwordable.rb
challah-1.2.5.pre lib/challah/concerns/user/passwordable.rb
challah-1.2.4 lib/challah/concerns/user/passwordable.rb
challah-1.2.3 lib/challah/concerns/user/passwordable.rb