docbrown/app/controllers/concerns/api/admin/users_controller.rb
Fernando Valverde 8c836430ca
API V1 transition (#17835)
* API Articles v0-v1 restructure

* Remove unused helper

* Bulk move API controllers into concerns + add V1 controllers

* Extract API routes + some fixes

* Fix v1 api_controller authenticate! + add more article_controller specs

* Completed spec/requests/api/v1/articles_spec.rb

* specs up to listings

* All v1 specs except for 9 skips

* mime_types cleanup + authenticate! relocation

Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
2022-06-23 14:26:00 -06:00

30 lines
806 B
Ruby

module Api
module Admin
module UsersController
extend ActiveSupport::Concern
def create
# NOTE: We can add an inviting user here, e.g. User.invite!(current_user, user_params).
User.invite!(user_params)
head :ok
end
private
# Given that we expect creators to use tools (e.g. their existing SSO,
# Zapier, etc) to post to this endpoint I wanted to keep the param
# structure as simple and flat as possible, hence slightly more manual
# param handling.
#
# NOTE: username is required for the validations on User to succeed.
def user_params
{
email: params.require(:email),
name: params[:name],
username: params[:email]
}.compact_blank
end
end
end
end