Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domain whitelist for account registration #1182

Merged
merged 3 commits into from
Oct 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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