Class: Cabal::API::User

Inherits:
Ohm::Model
  • Object
show all
Includes:
Ohm::Callbacks
Defined in:
lib/cabal/api/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#secret_keyObject

The secret key should not be saved plain, but we want to access it immediately after creation



13
14
15
# File 'lib/cabal/api/user.rb', line 13

def secret_key
  @secret_key
end

Instance Method Details

#authenticated_with?(secret_key) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
36
# File 'lib/cabal/api/user.rb', line 32

def authenticated_with?(secret_key)
  return false unless crypted_secret_key

  BCrypt::Password.new(crypted_secret_key) == secret_key
end

#before_createObject



27
28
29
30
# File 'lib/cabal/api/user.rb', line 27

def before_create
  set_access_key
  set_secret_key
end