Class: PostfixAdmin::Admin
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- PostfixAdmin::Admin
- Includes:
- DovecotCramMD5Password
- Defined in:
- lib/postfix_admin/admin.rb
Constant Summary
Constants inherited from ApplicationRecord
PostfixAdmin::ApplicationRecord::RE_DOMAIN_NAME_LIKE, PostfixAdmin::ApplicationRecord::RE_DOMAIN_NAME_LIKE_BASE, PostfixAdmin::ApplicationRecord::RE_DOMAIN_NAME_LIKE_WITH_ANCHORS, PostfixAdmin::ApplicationRecord::RE_EMAIL_LIKE, PostfixAdmin::ApplicationRecord::RE_EMAIL_LIKE_BASE, PostfixAdmin::ApplicationRecord::RE_EMAIL_LIKE_WITH_ANCHORS
Instance Attribute Summary collapse
-
#domain_ids ⇒ Object
Returns the value of attribute domain_ids.
Instance Method Summary collapse
- #has_admin?(admin) ⇒ Boolean
- #has_domain?(domain) ⇒ Boolean
- #super_admin=(value) ⇒ Object
- #super_admin? ⇒ Boolean
Methods included from DovecotCramMD5Password
#authenticate, #password_unencrypted=
Methods inherited from ApplicationRecord
#active_str, #has_timestamp_columns?, #inactive?, #set_current_time_to_timestamp_columns
Instance Attribute Details
#domain_ids ⇒ Object
Returns the value of attribute domain_ids.
17 18 19 |
# File 'lib/postfix_admin/admin.rb', line 17 def domain_ids @domain_ids end |
Instance Method Details
#has_admin?(admin) ⇒ Boolean
44 45 46 |
# File 'lib/postfix_admin/admin.rb', line 44 def has_admin?(admin) self == admin || super_admin? end |
#has_domain?(domain) ⇒ Boolean
48 49 50 |
# File 'lib/postfix_admin/admin.rb', line 48 def has_domain?(domain) !rel_domains.where(domain: ["ALL", domain.domain]).empty? end |
#super_admin=(value) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/postfix_admin/admin.rb', line 33 def super_admin=(value) if value domain_ids = self.rel_domain_ids.dup domain_ids << "ALL" self.rel_domain_ids = domain_ids save! else domain_admins.where(domain: "ALL").delete_all end end |
#super_admin? ⇒ Boolean
25 26 27 28 29 30 31 |
# File 'lib/postfix_admin/admin.rb', line 25 def super_admin? if @super_admin.nil? @super_admin = rel_domains.exists?("ALL") else @super_admin end end |