Mark,
Could you send me a stack trace for the error and DM gem versions. It's not
the error I would have expected. As far as devise is concerned, you just
need an encrypted_password method in your model, so something like:

    def encrypted_password
      attribute_get(:password_hash)
    end

(or, if you can, rename the :password_hash property to :encrypted_password).

- Jared

-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Mark Richman
Sent: Thursday, November 18, 2010 8:52 AM
To: DataMapper
Subject: [DataMapper] Re: Authentication

Thanks Jared. I was able to implement a custom encryptor per those
instructions:

module Devise
  module Encryptors
    class Sha1Base64 < Base
      def self.digest(password, stretches, salt, pepper)
        sha1 = Digest::SHA1.digest(password)
        Base64.strict_encode64(sha1)
      end
    end
  end
end

Yes, I realize there is no salt, etc. That's a legacy db for ya :-)

My next hurdle is this error: "Unknown column 'encrypted_password' in
'field list'". This is likely because my legacy database has no such
field. My user model is as follows:

class User
  include DataMapper::Resource
  include DataMapper::MassAssignmentSecurity

  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable, :lockable and :timeoutable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  storage_names[:default] = 'kms_User'
  property :id,            Serial,   :field =>
'UserId',           :required => true
  property :username,      String,   :field =>
'LoginId',          :required => true
  property :password_hash, String,   :field =>
'PasswordSHA1Hash', :required => true
  property :enabled,       Integer,  :field =>
'Enabled',          :required => true
  property :is_admin,      Integer,  :field =>
'IsSuperAdmin',     :required => true
  property :first_name,    String,   :field =>
'Name',             :required => true
  property :last_name,     String,   :field =>
'Surname',          :required => true
  property :born_on,       DateTime, :field => 'Birthday'
  property :email,         String,   :field =>
'Email',            :required => true
  property :site_url,      String,   :field =>
'SiteUrl',          :required => true
  property :blog_url,      String,   :field =>
'BlogUrl',          :required => true
  property :im_contact,    String,   :field =>
'IMContact',        :required => true
  property :skype_name,    String,   :field =>
'SkypeContact',     :required => true
  property :photo_id,      Integer,  :field => 'PhotoId'

 
attr_accessible :id, :username, :first_name, :last_name, :email, :born_on

end

I guess I need to do some custom logic for :password_hash? I realize
this is not a Devise support forum, but if you have any suggestions as
to what to do next, I'd appreciate it.

Thanks,
Mark

On Nov 17, 9:20 pm, "Jared Morgan" <[email protected]> wrote:
> dm-devise [https://github.com/jm81/dm-devise] might work for you. I'm
using
> it in a similar situation--Rails 3, DataMapper and custom hashing. The
> dm-devise gem just adds DataMapper support to devise
> [https://github.com/plataformatec/devise]. There's an article on the
devise
> wiki about using a custom hashing algorithm
athttps://github.com/plataformatec/devise/wiki/How-To:-Create-a-custom-...
> or.
>
> - Jared Morgan
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On
>
> Behalf Of Mark Richman
> Sent: Wednesday, November 17, 2010 7:38 PM
> To: DataMapper
> Subject: [DataMapper] Authentication
>
> Can someone recommend an authentication solution that works with
> DataMapper and Rails 3? I have used Authlogic in the past, but it
> appears to be intimately tied to ActiveRecord. I'll also require
> control over the password hashing algorithm used, since I have a
> custom one I'll need to use with my legacy database (where my user
> table lives).
>
> --
> You received this message because you are subscribed to the Google Groups
> "DataMapper" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group
athttp://groups.google.com/group/datamapper?hl=en.

-- 
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to