Class: Unidom::Visitor::Password

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Common::Concerns::ModelExtension
Defined in:
app/models/unidom/visitor/password.rb

Overview

Password 是密码。

Instance Method Summary collapse

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_textObject



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_contentObject



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

Returns:

  • (Boolean)


24
25
26
# File 'app/models/unidom/visitor/password.rb', line 24

def matched?(password)
  hash(password)==self.hashed_content
end