Class: Ridley::UserResource
- Defined in:
- lib/ridley/resources/user_resource.rb
Overview
Instance Method Summary collapse
- #authenticate(username, password) ⇒ Object
-
#regenerate_key(chef_user) ⇒ Ridley::UserObject
Retrieves a user from the remote connection matching the given chef_id and regenerates its private key.
Methods inherited from Resource
#all, #connection, #create, #delete, #delete_all, #find, #from_file, #from_json, #initialize, #new, representation, represented_by, resource_path, set_resource_path, #update
Constructor Details
This class inherits a constructor from Ridley::Resource
Instance Method Details
#authenticate(username, password) ⇒ Object
30 31 32 33 34 |
# File 'lib/ridley/resources/user_resource.rb', line 30 def authenticate(username, password) resp = request(:post, '/authenticate_user', {'name' => username, 'password' => password}.to_json) abort("Username mismatch: sent #{username}, received #{resp['name']}") unless resp['name'] == username resp['verified'] end |
#regenerate_key(chef_user) ⇒ Ridley::UserObject
Retrieves a user from the remote connection matching the given chef_id and regenerates its private key. An instance of the updated object will be returned and will have a value set for the ‘private_key’ accessor.
21 22 23 24 25 26 27 28 |
# File 'lib/ridley/resources/user_resource.rb', line 21 def regenerate_key(chef_user) unless chef_user = find(chef_user) abort Errors::ResourceNotFound.new("user '#{chef_user}' not found") end chef_user.private_key = true update(chef_user) end |