mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-06 15:05:26 +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
|
before_action :check_invite_users_permission, only: :invite_users
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
# Instantialize a new organization with the provided name
|
||||||
@org = Organization.new
|
@org = Organization.new
|
||||||
@org.name = params[:organization][:name]
|
@org.name = params[:organization][:name]
|
||||||
|
|
||||||
|
@ -23,9 +24,25 @@ module Users
|
||||||
end
|
end
|
||||||
|
|
||||||
def accept_resource
|
def accept_resource
|
||||||
resource = super
|
unless @org.valid?
|
||||||
resource.errors.add(:base, @org.errors.to_a.first) unless @org.valid?
|
# Find the user being invited
|
||||||
resource
|
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
|
end
|
||||||
|
|
||||||
def invite_users
|
def invite_users
|
||||||
|
|
Loading…
Reference in a new issue