mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
Merge pull request #304 from Ducz0r/lm-sci-650-fix-vol-2
Re-introduce fix for SCI-650 that was lost during merge [SCI-650]
This commit is contained in:
commit
b95855ca11
1 changed files with 20 additions and 3 deletions
|
@ -5,6 +5,7 @@ module Users
|
|||
before_action :check_invite_users_permission, only: :invite_users
|
||||
|
||||
def update
|
||||
# Instantialize a new organization with the provided name
|
||||
@org = Organization.new
|
||||
@org.name = params[:organization][:name]
|
||||
|
||||
|
@ -23,9 +24,25 @@ module Users
|
|||
end
|
||||
|
||||
def accept_resource
|
||||
resource = super
|
||||
resource.errors.add(:base, @org.errors.to_a.first) unless @org.valid?
|
||||
resource
|
||||
unless @org.valid?
|
||||
# Find the user being invited
|
||||
resource = User.find_by_invitation_token(
|
||||
update_resource_params[:invitation_token],
|
||||
false
|
||||
)
|
||||
|
||||
# Check if user's data (passwords etc.) is valid
|
||||
resource.assign_attributes(
|
||||
update_resource_params.except(:invitation_token)
|
||||
)
|
||||
resource.valid? # Call validation to generate errors
|
||||
|
||||
# In any case, add the organization name error
|
||||
resource.errors.add(:base, @org.errors.to_a.first)
|
||||
return resource
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def invite_users
|
||||
|
|
Loading…
Reference in a new issue