SimpleUserAuth
I put the code I used for user authentication in my first Rails app in this gem for use in my new apps. Feel free to use it wherever you want but keep in mind this was some of the first code I wrote in Ruby, so there are probably better ways to do certain aspects.
In your model
include SimpleUserAuth::Model
authenticate_by :email # Authenticate the user by email attribute
This gem assumes that you have a field called encrypted_password and a field called salt in your user model. It also creates accessors for password and current_password (for password changes).
In ApplicationController
include SimpleUserAuth::Controller
before_filter :authenticate # authenticate checks to see if the user is signed in
can_sign_in :user, :deny => :deny_access # uses the User model, if authentication fails deny_access will be called.
In your Gemfile
gem 'simple_user_auth', '>= 0.0.2'
License
SimpleUserAuth is released under the MIT license.