mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
(bug) As admin, unable to create a new member (#374)
This commit is contained in:
parent
e9a7b609bb
commit
b243800f5a
@ -8,6 +8,7 @@
|
|||||||
- Fix a bug: unable to book a space's slot with an existing reservation
|
- Fix a bug: unable to book a space's slot with an existing reservation
|
||||||
- Fix a bug: Unable to import accounts from SSO when the transformation modal was opened but leaved empty
|
- Fix a bug: Unable to import accounts from SSO when the transformation modal was opened but leaved empty
|
||||||
- Fix a bug: Unable to change the group of a user
|
- Fix a bug: Unable to change the group of a user
|
||||||
|
- Fix a bug: As admin, unable to create a new member (#374)
|
||||||
|
|
||||||
## v5.4.12 2022 July 06
|
## v5.4.12 2022 July 06
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class API::MembersController < API::ApiController
|
|||||||
def create
|
def create
|
||||||
authorize :user, :create_member?
|
authorize :user, :create_member?
|
||||||
|
|
||||||
@member = User.new(user_params.permit!)
|
@member = User.new(Members::MembersService.handle_organization(user_params.permit!))
|
||||||
members_service = Members::MembersService.new(@member)
|
members_service = Members::MembersService.new(@member)
|
||||||
|
|
||||||
if members_service.create(current_user, user_params)
|
if members_service.create(current_user, user_params)
|
||||||
|
@ -36,13 +36,7 @@ class Members::MembersService
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:invoicing_profile_attributes] && params[:invoicing_profile_attributes][:organization]
|
MembersService.handle_organization(params)
|
||||||
if params[:invoicing_profile_attributes][:organization] == 'false'
|
|
||||||
params[:invoicing_profile_attributes].reject! { |p| %w[organization_attributes organization].include?(p) }
|
|
||||||
else
|
|
||||||
params[:invoicing_profile_attributes].reject! { |p| p == 'organization' }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
not_complete = member.need_completion?
|
not_complete = member.need_completion?
|
||||||
up_result = member.update(params)
|
up_result = member.update(params)
|
||||||
@ -101,6 +95,18 @@ class Members::MembersService
|
|||||||
is_updated
|
is_updated
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.handle_organization(params)
|
||||||
|
return params unless params[:invoicing_profile_attributes] && params[:invoicing_profile_attributes][:organization]
|
||||||
|
|
||||||
|
if params[:invoicing_profile_attributes][:organization] == 'false'
|
||||||
|
params[:invoicing_profile_attributes].reject! { |p| %w[organization_attributes organization].include?(p) }
|
||||||
|
else
|
||||||
|
params[:invoicing_profile_attributes].reject! { |p| p == 'organization' }
|
||||||
|
end
|
||||||
|
|
||||||
|
params
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def notify_user_profile_complete(previous_state)
|
def notify_user_profile_complete(previous_state)
|
||||||
|
@ -25,6 +25,7 @@ class MembersTest < ActionDispatch::IntegrationTest
|
|||||||
phone: '0485232145'
|
phone: '0485232145'
|
||||||
},
|
},
|
||||||
invoicing_profile_attributes: {
|
invoicing_profile_attributes: {
|
||||||
|
organization: false,
|
||||||
address_attributes: {
|
address_attributes: {
|
||||||
address: '21 grand rue, 73110 Bourget-en-Huile'
|
address: '21 grand rue, 73110 Bourget-en-Huile'
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user