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
32 33 34 35 36 37 38 39 40 41 |
# File 'app/models/unidom/visitor/password.rb', line 32 def change_to(new_password) visitor = authenticating.visitor soft_destroy password = Password.new clear_text: new_password if password.save Authenticating.authenticate user, password else nil end end |
#clear_text ⇒ Object
15 16 17 |
# File 'app/models/unidom/visitor/password.rb', line 15 def clear_text '' end |
#clear_text=(password) ⇒ Object
19 20 21 22 |
# File 'app/models/unidom/visitor/password.rb', line 19 def clear_text=(password) generate_pepper_content self.hashed_content = hash password end |
#generate_pepper_content ⇒ Object
11 12 13 |
# File 'app/models/unidom/visitor/password.rb', line 11 def generate_pepper_content self.pepper_content = self.pepper_content||::SecureRandom.hex(self.class.columns_hash['pepper_content'].limit/2) end |
#matched?(password) ⇒ Boolean
24 25 26 |
# File 'app/models/unidom/visitor/password.rb', line 24 def matched?(password) hash(password)==self.hashed_content end |