Skip to content

Commit

Permalink
Changed Specific Email Domain Sign Up to Allowed Domains
Browse files Browse the repository at this point in the history
- changed all instances of previous name to AllowedDomains
  • Loading branch information
alihadimazeh committed Aug 12, 2024
1 parent ddcc607 commit 3af318f
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 33 deletions.
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -551,3 +551,9 @@ DEPENDENCIES
web-console (>= 4.2.1)
webdrivers
webmock

RUBY VERSION
ruby 3.1.0p0

BUNDLED WITH
2.3.3
8 changes: 4 additions & 4 deletions app/assets/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,9 @@
"invite": "Join by Invitation",
"approval": "Approve/Decline"
},
"specific_email_domain_signup": "Specific Email Domain Signup",
"specific_email_domain_signup_description": "Allow specific email domains to sign up. Format must be: @test.com,domain.com",
"enter_domain_signup_rule" : "Enter a specific domain signup rule"
"allowed_domains": "Allow Specific Email Domains",
"allowed_domains_signup_description": "Allow specific email domains to sign up. Format must be: @test.com,domain.com",
"enter_allowed_domains_rule" : "Enter the allowed domains"
}
},
"room_configuration": {
Expand Down Expand Up @@ -424,7 +424,7 @@
"helpcenter_updated": "The help center link has been updated.",
"terms_of_service_updated": "The terms of service have been updated.",
"maintenance_updated": "The maintenance banner has been updated.",
"specific_email_domain_signup_updated": "The specific email domain sign up has been updated"
"allowed_domains_signup_updated": "The specific email domain sign up has been updated"
},
"recording": {
"recording_visibility_updated": "The recording visibility has been updated.",
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/api/v1/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ def valid_invite_token
end

def valid_domain?
specific_domain_emails = SettingGetter.new(setting_name: 'SpecificEmailDomainSignUp', provider: current_provider).call
return true if specific_domain_emails.blank?
allowed_domains_emails = SettingGetter.new(setting_name: 'AllowedDomains', provider: current_provider).call
return true if allowed_domains_emails.blank?

domains = specific_domain_emails.split(',')
domains = allowed_domains_emails.split(',')
domains.each do |domain|
return true if create_user_params[:email].end_with?(domain)
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/external_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ def build_user_info(credentials)
end

def valid_domain?(email)
specific_domain_emails = SettingGetter.new(setting_name: 'SpecificEmailDomainSignUp', provider: current_provider).call
return true if specific_domain_emails.blank?
allowed_domain_emails = SettingGetter.new(setting_name: 'AllowedDomains', provider: current_provider).call
return true if allowed_domain_emails.blank?

domains = specific_domain_emails.split(',')
domains = allowed_domain_emails.split(',')
domains.each do |domain|
return true if email.end_with?(domain)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ import useRoles from '../../../../hooks/queries/admin/roles/useRoles';
export default function Registration() {
const { t } = useTranslation();
const { data: env } = useEnv();
const { data: siteSettings } = useSiteSettings(['RoleMapping', 'DefaultRole', 'ResyncOnLogin', 'RegistrationMethod', 'SpecificEmailDomainSignUp']);
const { data: siteSettings } = useSiteSettings(['RoleMapping', 'DefaultRole', 'ResyncOnLogin', 'RegistrationMethod', 'AllowedDomains']);
const { data: roles } = useRoles();
const updateRegistrationMethod = useUpdateSiteSetting('RegistrationMethod');
const updateDefaultRole = useUpdateSiteSetting('DefaultRole');
const updateRoleMapping = useUpdateSiteSetting('RoleMapping');
const updateDomainSignUp = useUpdateSiteSetting('SpecificEmailDomainSignUp');
const updateDomainSignUp = useUpdateSiteSetting('AllowedDomains');

return (
<>
Expand Down Expand Up @@ -102,13 +102,12 @@ export default function Registration() {
</Row>

<Row className="mb-3">
<strong> {t('admin.site_settings.registration.specific_email_domain_signup')} </strong>
<p className="text-muted">{t('admin.site_settings.registration.specific_email_domain_signup_description')}</p>
<strong> {t('admin.site_settings.registration.allowed_domains')} </strong>
<p className="text-muted">{t('admin.site_settings.registration.allowed_domains_signup_description')}</p>
<Stack direction="horizontal">
<input
className="form-control"
// TODO add proper placeholder and defultValue
placeholder={t('admin.site_settings.registration.enter_domain_signup_rule')}
placeholder={t('admin.site_settings.registration.enter_allowed_domains_rule')}
/>
<Button
variant="brand"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export default function useUpdateSiteSetting(name) {
case 'Maintenance':
toast.success(t('toast.success.site_settings.maintenance_updated'));
break;
case 'SpecificEmailDomainSignUp':
toast.success(t('toast.success.site_settings.specific_email_domain_signup_updated'));
case 'AllowedDomains':
toast.success(t('toast.success.site_settings.allowed_domains_signup_updated'));
break;
default:
toast.success(t('toast.success.site_settings.site_setting_updated'));
Expand Down
2 changes: 1 addition & 1 deletion app/services/tenant_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def create_site_settings
{ setting: Setting.find_by(name: 'DefaultRecordingVisibility'), provider: @provider, value: 'Published' },
{ setting: Setting.find_by(name: 'Maintenance'), provider: @provider, value: '' },
{ setting: Setting.find_by(name: 'SessionTimeout'), provider: @provider, value: '1' },
{ setting: Setting.find_by(name: 'SpecificEmailDomainSignUp'), value: '', provider: @provider }
{ setting: Setting.find_by(name: 'AllowedDomains'), value: '', provider: @provider }
]
end

Expand Down
23 changes: 23 additions & 0 deletions db/data/20240812210436_add_allowed_domains_to_site_settings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

class AddAllowedDomainsToSiteSettings < ActiveRecord::Migration[7.1]
def up
setting = Setting.find_or_create_by(name: 'AllowedDomains')

SiteSetting.create!(setting:, value: '', provider: 'greenlight') unless SiteSetting.exists?(setting:, provider: 'greenlight')

Tenant.find_each do |tenant|
SiteSetting.create!(setting:, value: '', provider: tenant.name) unless SiteSetting.exists?(setting:, provider: tenant.name)
end
end

def down
Tenant.find_each do |tenant|
SiteSetting.find_by(setting: Setting.find_by(name: 'Maintenance'), provider: tenant.name)&.destroy
end

SiteSetting.find_by(setting: Setting.find_by(name: 'Maintenance'), provider: 'greenlight')&.destroy

Setting.find_by(name: 'AllowedDomains')&.destroy
end
end
2 changes: 1 addition & 1 deletion db/data_schema.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DataMigrate::Data.define(version: 20240806205559)
DataMigrate::Data.define(version: 20240812210436)
8 changes: 4 additions & 4 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion spec/controllers/admin/tenants_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def create_settings_permissions_meetingoptions
Setting.find_or_create_by(name: 'HelpCenter')
Setting.find_or_create_by(name: 'Maintenance')
Setting.find_or_create_by(name: 'SessionTimeout')
Setting.find_or_create_by(name: 'SpecificEmailDomainSignUp')
Setting.find_or_create_by(name: 'AllowedDomains')

Permission.find_or_create_by(name: 'CreateRoom')
Permission.find_or_create_by(name: 'ManageUsers')
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/external_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,11 @@
end
end

context 'Specific Email Domain Signup' do
context 'Allowed Domains' do
context 'restricted domain not set' do
before do
site_settings = instance_double(SettingGetter)
allow(SettingGetter).to receive(:new).with(setting_name: 'SpecificEmailDomainSignUp', provider: 'greenlight').and_return(site_settings)
allow(SettingGetter).to receive(:new).with(setting_name: 'AllowedDomains', provider: 'greenlight').and_return(site_settings)
allow(site_settings).to receive(:call).and_return('')
end

Expand All @@ -355,7 +355,7 @@
context 'restricted domain set to 1 domain' do
before do
site_settings = instance_double(SettingGetter)
allow(SettingGetter).to receive(:new).with(setting_name: 'SpecificEmailDomainSignUp', provider: 'greenlight').and_return(site_settings)
allow(SettingGetter).to receive(:new).with(setting_name: 'AllowedDomains', provider: 'greenlight').and_return(site_settings)
allow(site_settings).to receive(:call).and_return('@domain.com')
end

Expand All @@ -376,7 +376,7 @@
context 'restricted domain set to multiple domain' do
before do
site_settings = instance_double(SettingGetter)
allow(SettingGetter).to receive(:new).with(setting_name: 'SpecificEmailDomainSignUp', provider: 'greenlight').and_return(site_settings)
allow(SettingGetter).to receive(:new).with(setting_name: 'AllowedDomains', provider: 'greenlight').and_return(site_settings)
allow(site_settings).to receive(:call).and_return('@example.com,@test.com,@domain.com')
end

Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@
end
end

context 'Specific Email Domain Signup' do
context 'Allowed Domains' do
context 'restricted domain not set' do
before do
site_settings = instance_double(SettingGetter)
allow(SettingGetter).to receive(:new).with(setting_name: 'SpecificEmailDomainSignUp', provider: 'greenlight').and_return(site_settings)
allow(SettingGetter).to receive(:new).with(setting_name: 'AllowedDomains', provider: 'greenlight').and_return(site_settings)
allow(site_settings).to receive(:call).and_return('')
end

Expand All @@ -318,7 +318,7 @@
context 'restricted domain set to 1 domain' do
before do
site_settings = instance_double(SettingGetter)
allow(SettingGetter).to receive(:new).with(setting_name: 'SpecificEmailDomainSignUp', provider: 'greenlight').and_return(site_settings)
allow(SettingGetter).to receive(:new).with(setting_name: 'AllowedDomains', provider: 'greenlight').and_return(site_settings)
allow(site_settings).to receive(:call).and_return('@domain.com')
end

Expand All @@ -336,7 +336,7 @@
context 'restricted domain set to multiple domain' do
before do
site_settings = instance_double(SettingGetter)
allow(SettingGetter).to receive(:new).with(setting_name: 'SpecificEmailDomainSignUp', provider: 'greenlight').and_return(site_settings)
allow(SettingGetter).to receive(:new).with(setting_name: 'AllowedDomains', provider: 'greenlight').and_return(site_settings)
allow(site_settings).to receive(:call).and_return('@example.com,@test.com,@domain.com')
end

Expand Down

0 comments on commit 3af318f

Please sign in to comment.