* Fix registered bugs in invitations * Update spec/requests/api/v0/admin/users_spec.rb Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Move to v1 spec --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
30 lines
831 B
Ruby
30 lines
831 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.merge(registered: false))
|
|
|
|
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
|