Commit d2f5ee21 authored by Timothy Andrew's avatar Timothy Andrew

Delete `EE::AuditorUser`

- There's no real need to have this module _and_ `EE::User`

- This commit moves the contents of `EE::AuditorUser` to `EE::User`
parent 42279725
module EE
# AuditorUser EE mixin
#
# This module is intended to encapsulate EE-specific model logic
# related to auditor (readonly access to all projects) users. It
# is prepended to the `User` model.
module AuditorUser
extend ActiveSupport::Concern
include AuditorUserHelper
included do
# We aren't using the `auditor?` method for the `if` condition here
# because `auditor?` returns `false` when the `auditor` column is `true`
# and the auditor add-on absent. We want to run this validation
# regardless of the add-on's presence, so we need to check the `auditor`
# column directly.
validate :auditor_requires_license_add_on, if: :auditor
validate :cannot_be_admin_and_auditor
end
def cannot_be_admin_and_auditor
if admin? && auditor?
errors.add(:admin, "user cannot also be an Auditor.")
end
end
def auditor_requires_license_add_on
unless license_allows_auditor_user?
errors.add(:auditor, 'user cannot be created without the "GitLab_Auditor_User" addon')
end
end
def auditor?
license_allows_auditor_user? && self.auditor
end
def admin_or_auditor?
admin? || auditor?
end
end
end
......@@ -5,6 +5,37 @@ module EE
# and be prepended in the `User` model
module User
extend ActiveSupport::Concern
include AuditorUserHelper
included do
# We aren't using the `auditor?` method for the `if` condition here
# because `auditor?` returns `false` when the `auditor` column is `true`
# and the auditor add-on absent. We want to run this validation
# regardless of the add-on's presence, so we need to check the `auditor`
# column directly.
validate :auditor_requires_license_add_on, if: :auditor
validate :cannot_be_admin_and_auditor
end
def cannot_be_admin_and_auditor
if admin? && auditor?
errors.add(:admin, "user cannot also be an Auditor.")
end
end
def auditor_requires_license_add_on
unless license_allows_auditor_user?
errors.add(:auditor, 'user cannot be created without the "GitLab_Auditor_User" addon')
end
end
def auditor?
license_allows_auditor_user? && self.auditor
end
def admin_or_auditor?
admin? || auditor?
end
def access_level
if admin?
......
......@@ -11,7 +11,6 @@ class User < ActiveRecord::Base
include TokenAuthenticatable
prepend EE::GeoAwareAvatar
prepend EE::User
prepend EE::AuditorUser
DEFAULT_NOTIFICATION_LEVEL = :participating
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment