fix: Macros authorizations (#5779)

Macros policy update.

ref: #5730
This commit is contained in:
Tejaswini Chile
2022-11-08 07:16:00 +05:30
committed by GitHub
parent 479d88a480
commit 48373628a1
8 changed files with 177 additions and 38 deletions

View File

@@ -92,17 +92,13 @@ class User < ApplicationRecord
has_many :team_members, dependent: :destroy_async
has_many :teams, through: :team_members
has_many :articles, foreign_key: 'author_id', dependent: :nullify
has_many :portal_members,
class_name: :PortalMember,
dependent: :destroy_async
has_many :portals,
through: :portal_members,
class_name: :Portal,
dependent: :nullify,
source: :portal
has_many :macros, foreign_key: 'created_by_id', dependent: :destroy_async
has_many :portal_members, class_name: :PortalMember, dependent: :destroy_async
has_many :portals, through: :portal_members, source: :portal,
class_name: :Portal,
dependent: :nullify
has_many :macros, foreign_key: 'created_by_id'
before_validation :set_password_and_uid, on: :create
after_destroy :remove_macros
scope :order_by_full_name, -> { order('lower(name) ASC') }
@@ -205,4 +201,10 @@ class User < ApplicationRecord
count: notifications.where(account_id: account_id).count
}
end
private
def remove_macros
macros.personal.destroy_all
end
end