Read my latest article: 8 things I look for in a Ruby on Rails app (posted Thu, 06 Jul 2017 17:59:00 GMT)

Rails Login with MD5

Posted by Mon, 14 Mar 2005 03:14:03 GMT

I am working on migrating an existing system that utilizes MD5 rather than SHA1 for password encryption so I needed to make a few adjustments to the login process.

I had issued the following command which created some objects to work with.
./script/generate login User

My existing system also uses the email address as the login username, so I modified the the file ./app/models/user.rb:

I changed this:
  def self.sha1(pass)
    Digest::SHA1.hexdigest("---changme--#{pass}--")
  end
to:
  def self.md5(pass)
    Digest::MD5.hexdigest("--my-salt--#{pass}")
  end

Then I went and changed instances of sha1 in user.rb to md5.

The next step was to modify the field that authentication was checking the database with.

I changed this:
  def self.authenticate(login, pass)
    find_first(["login = ? AND password = ?", login, sha1(pass)])
  end
to this:
  def self.authenticate(login, pass)
    find_first(["email = ? AND password = ?", login, md5(pass)])
  end

The last step was to modify the table that the system looks in for the users who can login to the system. Still in user.rb, I added this to the top of the User class.

class User < ActiveRecord::Base

def self.table_name() "employees" end

...
end

Updating the default template

Posted by Mon, 14 Mar 2005 00:32:37 GMT

Playing around with the template a bit. (css and the header image..)

BloGTK and Typo

Posted by Sun, 13 Mar 2005 23:34:36 GMT

When you run BloGTK and Typo together, make sure you set the API to MoveableType in your Preferences.

..and a screenshot of me posting this entry.

Typo on PostgreSQL

Posted by Sun, 13 Mar 2005 21:02:00 GMT

As Typo only supported SQLite and MySQL so far, I submitted a PostgreSQL schema file for the project. This new blog is running on PostgreSQL 8.0 and Rails!

I am going to use this blog to follow my Rails-related projects..and post tips and tricks!

Cheers

UPDATE Links have been updated as the original typo svn/trac is gone.

Older posts: 1 ... 97 98 99