Class: Unidom::Visitor::Password
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Unidom::Visitor::Password
- Includes:
- Common::Concerns::ModelExtension, Concerns::AsCredential
- Defined in:
- app/models/unidom/visitor/password.rb
Overview
Password 是密码。
Instance Method Summary collapse
- #change_to(new_password) ⇒ Object
- #clear_text ⇒ Object
- #clear_text=(password) ⇒ Object
- #generate_pepper_content ⇒ Object
- #matched?(password) ⇒ Boolean
Instance Method Details
#change_to(new_password) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/unidom/visitor/password.rb', line 37 def change_to(new_password) visitor = authenticating.visitor soft_destroy authenticating.soft_destroy password = self.class.new clear_text: new_password, opened_at: Time.now if password.save Unidom::Visitor::Authenticating.authenticate visitor, password else nil end end |
#clear_text ⇒ Object
19 20 21 |
# File 'app/models/unidom/visitor/password.rb', line 19 def clear_text @clear_text end |
#clear_text=(password) ⇒ Object
23 24 25 26 27 |
# File 'app/models/unidom/visitor/password.rb', line 23 def clear_text=(password) @clear_text = password generate_pepper_content self.hashed_content = hash password end |
#generate_pepper_content ⇒ Object
15 16 17 |
# File 'app/models/unidom/visitor/password.rb', line 15 def generate_pepper_content self.pepper_content = self.pepper_content||SecureRandom.hex(self.class.columns_hash['pepper_content'].limit/2) end |
#matched?(password) ⇒ Boolean
29 30 31 |
# File 'app/models/unidom/visitor/password.rb', line 29 def matched?(password) hash(password)==self.hashed_content end |