Module: Plutonium::ApiClient::Concerns::CreateApiClient
- Extended by:
- ActiveSupport::Concern
- Includes:
- Interaction::Concerns::Scoping
- Defined in:
- lib/plutonium/api_client/concerns/create_api_client.rb
Overview
CreateApiClient provides the core logic for creating API client accounts.
Include this in your CreateInteraction and implement the required methods.
Defined Under Namespace
Classes: CredentialsPage
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/plutonium/api_client/concerns/create_api_client.rb', line 37 def execute password = generate_secure_password rodauth_instance.create_account( login: login, password: password ) # Rodauth internal_request returns nil, so we need to find the account api_client = api_client_class.find_by!(login: login) create_membership!(api_client) if entity_scoped_api_client? succeed(api_client).with_render_response( credentials_page_class.new( login: api_client.login, password: password, parent: scoped_parent ) ) rescue ActiveRecord::RecordNotFound => e failed(login: "Failed to create account: #{e.}") rescue => e failed(login: e.) end |