Skip to content

Commit

Permalink
Merge pull request #1182 from RocketChat/domain-whitelist
Browse files Browse the repository at this point in the history
Domain whitelist for account registration
  • Loading branch information
marceloschmidt committed Oct 22, 2015
2 parents 4a03ef3 + b74dd61 commit e8ba7d5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"Access_online_demo" : "Access the online demo",
"Access_Online_Demo" : "Access the Online Demo",
"Accounts" : "Accounts",
"Accounts_AllowedDomainsList" : "Comma-separated list of allowed domains",
"Accounts_denyUnverifiedEmail" : "Deny unverified e-mail",
"Accounts_EmailVerification" : "E-mail Verification",
"Accounts_OAuth_Facebook" : "Facebook Login",
Expand Down
1 change: 1 addition & 0 deletions i18n/pt.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"Access_online_demo" : "Acesse o demo online",
"Access_Online_Demo" : "Acesse o Demo Online",
"Accounts" : "Contas",
"Accounts_AllowedDomainsList" : "Lista de domínios permitidos (separados por vírgula)",
"Accounts_denyUnverifiedEmail" : "Proibir e-mail não verificado",
"Accounts_EmailVerification" : "Verificação de E-mail",
"Accounts_OAuth_Facebook" : "Login do Facebook",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-lib/settings/server/startup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ RocketChat.settings.addGroup 'Accounts'
RocketChat.settings.add 'Accounts_RegistrationRequired', true, { type: 'boolean', group: 'Accounts', public: true, section: 'Registration' }
RocketChat.settings.add 'Accounts_EmailVerification', false, { type: 'boolean', group: 'Accounts', public: true, section: 'Registration' }
RocketChat.settings.add 'Accounts_ManuallyApproveNewUsers', false, { type: 'boolean', group: 'Accounts', section: 'Registration' }
RocketChat.settings.add 'Accounts_AllowedDomainsList', '', { type: 'string', group: 'Accounts', public: true, section: 'Registration' }

RocketChat.settings.add 'Accounts_AvatarStoreType', 'GridFS', { type: 'string', group: 'Accounts', section: 'Avatar' }
RocketChat.settings.add 'Accounts_AvatarStorePath', '/var/www/rocket.chat/uploads/avatar/', { type: 'string', group: 'Accounts', section: 'Avatar' }
Expand Down
15 changes: 14 additions & 1 deletion server/lib/accounts.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Deny Account.createUser in client
Accounts.config { forbidClientAccountCreation: true }
accountsConfig = { forbidClientAccountCreation: true }

if RocketChat.settings.get('Account_AllowedDomainsList')
domainWhiteList = _.map RocketChat.settings.get('Account_AllowedDomainsList').split(','), (domain) -> domain.trim()
accountsConfig.restrictCreationByEmailDomain = (email) ->
ret = false
for domain in domainWhiteList
if email.match(domain + '$')
ret = true
break;

return ret

Accounts.config accountsConfig

Accounts.emailTemplates.siteName = RocketChat.settings.get 'Site_Name';
Accounts.emailTemplates.from = "#{RocketChat.settings.get 'Site_Name'} <#{RocketChat.settings.get 'From_Email'}>";
Expand Down

0 comments on commit e8ba7d5

Please sign in to comment.