FEATURE: add setting auto_approve_email_domains to auto approve users (#9323)

* FEATURE: add setting `auto_approve_email_domains` to auto approve users

This commit adds a new site setting `auto_approve_email_domains` to
auto approve users based on their email address domain.

Note that if a domain already exists in `email_domains_whitelist` then
`auto_approve_email_domains` needs to be duplicated there as well,
since users won’t be able to register with email address that is
not allowed in `email_domains_whitelist`.

* Update config/locales/server.en.yml

Co-Authored-By: Robin Ward <robin.ward@gmail.com>
This commit is contained in:
Arpit Jalan
2020-03-31 23:59:15 +05:30
committed by GitHub
parent 0e3fa4072f
commit b2a0d34bb7
8 changed files with 65 additions and 5 deletions

View File

@@ -59,7 +59,7 @@ describe InviteRedeemer do
end
describe "#redeem" do
fab!(:invite) { Fabricate(:invite) }
fab!(:invite) { Fabricate(:invite, email: "foobar@example.com") }
let(:name) { 'john snow' }
let(:username) { 'kingofthenorth' }
let(:password) { 'know5nOthiNG' }
@@ -102,6 +102,16 @@ describe InviteRedeemer do
expect(user.approved).to eq(true)
end
it "should redeem the invite if invited by non staff and approve if email in auto_approve_email_domains setting" do
SiteSetting.must_approve_users = true
SiteSetting.auto_approve_email_domains = "example.com"
user = invite_redeemer.redeem
expect(user.name).to eq(name)
expect(user.username).to eq(username)
expect(user.approved).to eq(true)
end
it "should not blow up if invited_by user has been removed" do
invite.invited_by.destroy!
invite.reload