fix: project permission and update user lastname

This commit is contained in:
vilet.yy 2021-06-29 10:36:58 +08:00
parent 7b27ed71ca
commit 0e7f3a8905
2 changed files with 6 additions and 2 deletions

View File

@ -65,7 +65,7 @@ module ProjectOperable
if owner.is_a?(User)
managers.exists?(user_id: user.id)
elsif owner.is_a?(Organization)
managers.exists?(user_id: user.id) || owner.is_only_admin?(user.id)
managers.exists?(user_id: user.id) || owner.is_owner?(user.id) || owner.is_only_admin?(user.id)
else
false
end

View File

@ -186,7 +186,7 @@ class User < Owner
:show_email, :show_location, :show_department,
:technical_title, :province, :city, :custom_department, to: :user_extension, allow_nil: true
before_save :update_hashed_password
before_save :update_hashed_password, :set_lastname
after_create do
SyncTrustieJob.perform_later("user", 1) if allow_sync_to_trustie?
end
@ -779,6 +779,10 @@ class User < Owner
self.laboratory = Laboratory.current if laboratory_id.blank?
end
def set_lastname
self.lastname = self.nickname if changes[:nickname].present?
end
end