Created
August 21, 2011 18:35
-
-
Save mattbrictson/1160970 to your computer and use it in GitHub Desktop.
Setting up clearance gem to use bcrypt on a new project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bcrypt_password_strategy' | |
Clearance.configure do |config| | |
config.password_strategy = BcryptPasswordStrategy | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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