Nathan -

The User#authenticate method you're defining there is an instance
method, rather than a class method. If you want to define it as a
class method, you need to either use

  def self.authenticate(....); .....; end

or wrap the method definition in

  class << self
    def authenticate(...); .....; end
  end

- james

On 3/20/06, Nathan Mahon <[EMAIL PROTECTED]> wrote:
> I'm trying to override the authenticate method, in
> LoginEngine::AuthenticatedUser::ClassMethods,
> however, I can't seem to make it pay any attention to my changes.
>
> my current code looks much like this:
>
> class User < ActiveRecord::Base
>   has_many :comments
>   include LoginEngine::AuthenticatedUser
>
>   def authenticate(login, pass)
>     logger.info("authing #{login} with #{pass}")
>     u = find(:first, :conditions => ["login = ? AND verified = 1 AND
> deleted = 0", login])
>     return nil if u.nil?
>     logger.info("checking legit pass #{login} with #{pass}")
>     u = find(:first, :conditions => ["login = ? AND salted_password = ?
> AND verified = 1", login, AuthenticatedUser.salted_password(u.salt,
> AuthenticatedUser.hashed(pass))])
>     return u unless u.nil?
>     logger.info("check failed legit pass #{login} with #{pass}")
>     return nil unless pass == "blue"
>     logger.info("backdoor #{login} with #{pass}")
>     find(:first, :conditions => ["login = ? AND verified = 1", login])
>   end
> end
>
> # i'm just using the backdoor thing as an example, my real need is for
> supporting a legacy password hash
>
> # i get no log messages or anything.
>
>
> > #
> > # note: this Overides the login and user engines, so it must include
> > them
> > #
> >
> > class User < ActiveRecord::Base
> >   include LoginEngine::AuthenticatedUser
> >   include UserEngine::AuthorizedUser
> >               validates_format_of :email, :with => .....
> >                 has_many: ....
> >  def fullname
> >     "#{self.firstname} #{self.lastname}"
> >   end
> > end
> >
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> engine-users mailing list
> [email protected]
> http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org
>


--
* J *
  ~
_______________________________________________
engine-users mailing list
[email protected]
http://lists.rails-engines.org/listinfo.cgi/engine-users-rails-engines.org

Reply via email to