Created
April 12, 2016 16:11
-
-
Save smathy/e29e0b531a7a7b9a0e3b5cbff9f57139 to your computer and use it in GitHub Desktop.
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
User # autoload | |
class User | |
class Twin | |
class Authentication < ::Disposable::Twin | |
include Sync | |
include Save | |
property :state | |
property :password_digest | |
include States | |
def has_password? | |
password_digest.present? | |
end | |
def authenticated? plain_password | |
active? && password_digest && password == plain_password | |
end | |
def password= plain_password | |
self.password_digest = BCrypt::Password.create plain_password | |
sync | |
end | |
def password | |
BCrypt::Password.new password_digest | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment