mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-14 05:05:55 +08:00
30 lines
553 B
Ruby
30 lines
553 B
Ruby
class Users::InvitationsController < Devise::InvitationsController
|
|
|
|
def update
|
|
@org = Organization.new
|
|
@org.name = params[:organization][:name]
|
|
|
|
super do |user|
|
|
if user.errors.empty?
|
|
@org.created_by = user
|
|
@org.save
|
|
|
|
UserOrganization.create(
|
|
user: user,
|
|
organization: @org,
|
|
role: 'admin'
|
|
)
|
|
end
|
|
end
|
|
end
|
|
|
|
def accept_resource
|
|
resource = super
|
|
|
|
if not @org.valid?
|
|
resource.errors.add(:base, @org.errors.to_a.first)
|
|
end
|
|
|
|
resource
|
|
end
|
|
end
|