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

Default oauth role #6028

Merged
merged 3 commits into from
Feb 16, 2017
Merged

Default oauth role #6028

merged 3 commits into from
Feb 16, 2017

Conversation

marceloschmidt
Copy link
Member

@RocketChat/core

Closes #5842

image

@@ -95,6 +95,13 @@ Accounts.insertUserDoc = _.wrap(Accounts.insertUserDoc, function(insertUserDoc,

delete user.globalRoles;

if (!(user.services && user.services.password)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little bit confused to me, why not:
if (!user.services || !user.services.password) {

@@ -95,6 +95,13 @@ Accounts.insertUserDoc = _.wrap(Accounts.insertUserDoc, function(insertUserDoc,

delete user.globalRoles;

if (!(user.services && user.services.password)) {
const defaultAuthServiceRoles = (RocketChat.settings.get('Accounts_Registration_AuthenticationServices_Default_Roles') + '').split(',');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks less hack:

const defaultAuthServiceRoles = String(RocketChat.settings.get('Accounts_Registration_AuthenticationServices_Default_Roles')).split(',');

What do you think?

if (!(user.services && user.services.password)) {
const defaultAuthServiceRoles = (RocketChat.settings.get('Accounts_Registration_AuthenticationServices_Default_Roles') + '').split(',');
if (defaultAuthServiceRoles.length > 0) {
roles = roles.concat(_.map(defaultAuthServiceRoles, s.trim));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets try to prevent use underscore when we have native functions?

roles = roles.concat(defaultAuthServiceRoles.map(i => i.trim()));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request] Specify default role for OAuth users
3 participants