Class: Unidom::Visitor::Password
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Unidom::Visitor::Password
- Includes:
- Common::Concerns::ModelExtension
- 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
35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/unidom/visitor/password.rb', line 35 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
17 18 19 |
# File 'app/models/unidom/visitor/password.rb', line 17 def clear_text @clear_text end |
#clear_text=(password) ⇒ Object
21 22 23 24 25 |
# File 'app/models/unidom/visitor/password.rb', line 21 def clear_text=(password) @clear_text = password generate_pepper_content self.hashed_content = hash password end |
#generate_pepper_content ⇒ Object
13 14 15 |
# File 'app/models/unidom/visitor/password.rb', line 13 def generate_pepper_content self.pepper_content = self.pepper_content||::SecureRandom.hex(self.class.columns_hash['pepper_content'].limit/2) end |
#matched?(password) ⇒ Boolean
27 28 29 |
# File 'app/models/unidom/visitor/password.rb', line 27 def matched?(password) hash(password)==self.hashed_content end |