From 5fb0c808912e9332eeab76a5226b11e14381034b Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 28 Aug 2025 15:03:23 +0530 Subject: [PATCH] feat: move saml methods to enterprise --- app/models/user.rb | 9 +++++---- enterprise/app/models/enterprise/concerns/user.rb | 13 +++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index ea20af97e..b4be58574 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -152,17 +152,18 @@ class User < ApplicationRecord mutations_from_database.changed?('email') end - # SAML authentication methods + # SAML methods - fallback implementations for Community Edition + # These will be overridden in Enterprise Edition via include_mod_with def saml_user? - provider == 'saml' + false end def convert_to_saml! - update!(provider: 'saml') + # No-op in Community Edition end def password_authentication_allowed? - !saml_user? + true end def self.from_email(email) diff --git a/enterprise/app/models/enterprise/concerns/user.rb b/enterprise/app/models/enterprise/concerns/user.rb index 7231decb7..1f1e6a6c7 100644 --- a/enterprise/app/models/enterprise/concerns/user.rb +++ b/enterprise/app/models/enterprise/concerns/user.rb @@ -13,4 +13,17 @@ module Enterprise::Concerns::User errors.add(:base, 'User limit reached. Please purchase more licenses from super admin') if User.count >= ChatwootHub.pricing_plan_quantity end + + # SAML authentication methods (Enterprise only) + def saml_user? + provider == 'saml' + end + + def convert_to_saml! + update!(provider: 'saml') + end + + def password_authentication_allowed? + !saml_user? + end end