@ -2,21 +2,6 @@
accountsConfig = { forbidClientAccountCreation: true , loginExpirationInDays: RocketChat . settings . get ' Accounts_LoginExpiration ' }
Accounts . config accountsConfig
RocketChat . settings . get ' Accounts_AllowedDomainsList ' , (_id, value) ->
domainWhiteList = _ . map value . split ( ' , ' ) , (domain) -> domain . trim ( )
restrictCreationByEmailDomain = if domainWhiteList . length == 1 then domainWhiteList [ 0 ] else (email) ->
ret = false
for domain in domainWhiteList
if email . match ( ' @ ' + RegExp . escape ( domain ) + ' $ ' )
ret = true
break ;
return ret
delete Accounts . _options [ ' restrictCreationByEmailDomain ' ]
if not _ . isEmpty value
Accounts . config ( { restrictCreationByEmailDomain: restrictCreationByEmailDomain } ) ;
Accounts.emailTemplates.siteName = RocketChat . settings . get ' Site_Name ' ;
Accounts.emailTemplates.from = " #{ RocketChat . settings . get ' Site_Name ' } < #{ RocketChat . settings . get ' From_Email ' } > " ;
@ -106,7 +91,9 @@ Accounts.insertUserDoc = _.wrap Accounts.insertUserDoc, (insertUserDoc, options,
RocketChat . authz . addUserRoles ( _id , roles )
RocketChat . callbacks . run ' afterCreateUser ' , options , user
Meteor . defer ->
RocketChat . callbacks . run ' afterCreateUser ' , options , user
return _id
Accounts . validateLoginAttempt (login) ->
@ -115,6 +102,10 @@ Accounts.validateLoginAttempt (login) ->
if login . allowed isnt true
return login . allowed
# bypass for livechat users
if login . user . type is ' visitor '
return true
if ! ! login . user ? . active isnt true
throw new Meteor . Error ' error-user-is-not-activated ' , ' User is not activated ' , { function: ' Accounts.validateLoginAttempt ' }
return false
@ -136,6 +127,35 @@ Accounts.validateLoginAttempt (login) ->
return true
Accounts . validateNewUser (user) ->
# bypass for livechat users
if user . type is ' visitor '
return true
if RocketChat . settings . get ( ' Accounts_Registration_AuthenticationServices_Enabled ' ) is false and RocketChat . settings . get ( ' LDAP_Enable ' ) is false and not user . services ? . password ?
throw new Meteor . Error ' registration-disabled-authentication-services ' , ' User registration is disabled for authentication services '
return true
Accounts . validateNewUser (user) ->
# bypass for livechat users
if user . type is ' visitor '
return true
domainWhiteList = RocketChat . settings . get ( ' Accounts_AllowedDomainsList ' )
if _ . isEmpty s . trim ( domainWhiteList )
return true
domainWhiteList = _ . map ( domainWhiteList . split ( ' , ' ) , (domain) -> domain . trim ( ) )
if user . emails ? . length > 0
ret = false
email = user . emails [ 0 ] . address
for domain in domainWhiteList
if email . match ( ' @ ' + RegExp . escape ( domain ) + ' $ ' )
ret = true
break
return ret
return true