Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 28 lines (21 sloc) 0.53 kb
be37c35 BCrypt for passwords
Dan Croak and Gabe Berke-Williams authored
1 module Clearance
2 module PasswordStrategies
3 module BCrypt
4 require 'bcrypt'
5
6 extend ActiveSupport::Concern
7
8 def authenticated?(password)
9 ::BCrypt::Password.new(encrypted_password) == password
10 end
11
12 def password=(new_password)
13 @password = new_password
78f8f0f @croaky Apply style guidelines
croaky authored
14
be37c35 BCrypt for passwords
Dan Croak and Gabe Berke-Williams authored
15 if new_password.present?
16 self.encrypted_password = encrypt(new_password)
17 end
18 end
19
20 private
21
22 def encrypt(password)
23 ::BCrypt::Password.create(password)
24 end
25 end
26 end
27 end
Something went wrong with that request. Please try again.