Class: GlobalUser
- Inherits:
-
Redis::NativeHash
- Object
- Redis::NativeHash
- GlobalUser
- Defined in:
- lib/global_user.rb
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ GlobalUser
constructor
A new instance of GlobalUser.
- #namespace ⇒ Object
- #password=(value) ⇒ Object
- #password?(value) ⇒ Boolean
- #salt ⇒ Object
- #save ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ GlobalUser
Returns a new instance of GlobalUser.
6 7 8 9 |
# File 'lib/global_user.rb', line 6 def initialize(data = {}) super(namespace) update(data) end |
Instance Method Details
#namespace ⇒ Object
11 |
# File 'lib/global_user.rb', line 11 def namespace; :global_user; end |
#password=(value) ⇒ Object
17 18 19 |
# File 'lib/global_user.rb', line 17 def password=(value) self[:password_hash] = Singularity::PasswordHash.generate(value, salt) end |
#password?(value) ⇒ Boolean
21 22 23 24 25 |
# File 'lib/global_user.rb', line 21 def password?(value) return false unless value.present? return false unless self[:password_hash].present? Singularity::PasswordHash.new(self[:password_hash]).matches?(value, salt) end |
#salt ⇒ Object
13 14 15 |
# File 'lib/global_user.rb', line 13 def salt self[:password_salt] ||= SecureRandom.hex(32) end |
#save ⇒ Object
27 28 29 30 |
# File 'lib/global_user.rb', line 27 def save self.key = login unless login.nil? super end |