Skip to content
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
6 changes: 4 additions & 2 deletions packages/rocketchat-authorization/server/models/Roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ class ModelRoles extends RocketChat.models._Base {
const roleScope = (role && role.scope) || 'Users';
const model = RocketChat.models[roleScope];

return model && model.addRolesByUserId && model.addRolesByUserId(userId, roleName, scope);
model && model.addRolesByUserId && model.addRolesByUserId(userId, roleName, scope);
}
return true;
}

removeUserRoles(userId, roles, scope) {
Expand All @@ -58,8 +59,9 @@ class ModelRoles extends RocketChat.models._Base {
const roleScope = (role && role.scope) || 'Users';
const model = RocketChat.models[roleScope];

return model && model.removeRolesByUserId && model.removeRolesByUserId(userId, roleName, scope);
model && model.removeRolesByUserId && model.removeRolesByUserId(userId, roleName, scope);
}
return true;
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
"Accounts_OAuth_Wordpress_id": "WordPress Id",
"Accounts_OAuth_Wordpress_secret": "WordPress Secret",
"Accounts_PasswordReset": "Password Reset",
"Accounts_Registration_AuthenticationServices_Default_Roles": "Default Roles for Authentication Services",
"Accounts_Registration_AuthenticationServices_Default_Roles_Description": "Default roles (comma-separated) users will be given when registering through authentication services",
"Accounts_Registration_AuthenticationServices_Enabled": "Registration with Authentication Services",
"Accounts_RegistrationForm": "Registration Form",
"Accounts_RegistrationForm_Disabled": "Disabled",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-lib/server/startup/settings.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RocketChat.settings.addGroup 'Accounts', ->
@add 'Accounts_RegistrationForm_SecretURL', Random.id(), { type: 'string' }
@add 'Accounts_RegistrationForm_LinkReplacementText', 'New user registration is currently disabled', { type: 'string', public: true }
@add 'Accounts_Registration_AuthenticationServices_Enabled', true, { type: 'boolean', public: true }
@add 'Accounts_Registration_AuthenticationServices_Default_Roles', 'user', { type: 'string', enableQuery: { _id: 'Accounts_Registration_AuthenticationServices_Enabled', value: true } }
@add 'Accounts_PasswordReset', true, { type: 'boolean', public: true }

@add 'Accounts_CustomFields', '', { type: 'code', public: true, i18nLabel: 'Custom_Fields' }
Expand Down
7 changes: 7 additions & 0 deletions server/lib/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ Accounts.insertUserDoc = _.wrap(Accounts.insertUserDoc, function(insertUserDoc,

delete user.globalRoles;

if (!user.services || !user.services.password) {
const defaultAuthServiceRoles = String(RocketChat.settings.get('Accounts_Registration_AuthenticationServices_Default_Roles')).split(',');
if (defaultAuthServiceRoles.length > 0) {
roles = roles.concat(defaultAuthServiceRoles.map(s => s.trim()));
}
}

if (!user.type) {
user.type = 'user';
}
Expand Down