Skip to content

Instantly share code, notes, and snippets.

@mattbrictson
Created August 21, 2011 18:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbrictson/1160970 to your computer and use it in GitHub Desktop.
Save mattbrictson/1160970 to your computer and use it in GitHub Desktop.
Setting up clearance gem to use bcrypt on a new project
require 'bcrypt'
module BcryptPasswordStrategy
def authenticated?(password)
BCrypt::Password.new(encrypted_password) == password rescue false
end
protected
def encrypt_password
if password.present?
self.encrypted_password = BCrypt::Password.create(password)
end
end
end
require 'bcrypt_password_strategy'
Clearance.configure do |config|
config.password_strategy = BcryptPasswordStrategy
end
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'clearance'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment