diff --git a/bin/cli-users b/bin/cli-users index 248bea523..35ae78ba5 100755 --- a/bin/cli-users +++ b/bin/cli-users @@ -34,11 +34,11 @@ function getUserCreateAnswers(options) { password: options.password, confirmPassword: options.password, username: options.name, - roles: [] + role: 'COMMENTER' }; if (options.role && USER_ROLES.indexOf(options.role) > -1) { - user.roles = [options.role]; + user.roles = options.role; } return Promise.resolve(user); @@ -87,9 +87,9 @@ function getUserCreateAnswers(options) { } }, { - name: 'roles', + name: 'role', message: 'User Role', - type: 'checkbox', + type: 'list', choices: USER_ROLES } ]); @@ -106,13 +106,7 @@ async function createUser(options) { } const user = await UsersService.createLocalUser(answers.email.trim(), answers.password.trim(), answers.username.trim()); - - if (answers.roles.length > 0) { - for (const role of answers.roles) { - await UsersService.addRoleToUser(user.id, role); - } - } - + await UsersService.setRole(user.id, answers.role); await UsersService.sendEmailConfirmation(user, answers.email.trim()); console.log(`Created User ${user.id}.`); @@ -250,7 +244,7 @@ function listUsers() { user.id, user.username, user.profiles.map((p) => p.provider).join(', '), - user.roles.join(', '), + user.role, user.status, state ]); diff --git a/client/coral-admin/src/components/CommentLabels.js b/client/coral-admin/src/components/CommentLabels.js index bff4f575a..a40777c40 100644 --- a/client/coral-admin/src/components/CommentLabels.js +++ b/client/coral-admin/src/components/CommentLabels.js @@ -17,7 +17,7 @@ function getUserFlaggedType(actions) { .some((action) => action.__typename === 'FlagAction' && action.user && - action.user.roles.some((role) => staffRoles.includes(role)) + staffRoles.includes(action.user.role) ) ? 'Staff' : 'User'; } diff --git a/client/coral-admin/src/containers/CommentLabels.js b/client/coral-admin/src/containers/CommentLabels.js index 1d57aa526..abc7d0bed 100644 --- a/client/coral-admin/src/containers/CommentLabels.js +++ b/client/coral-admin/src/containers/CommentLabels.js @@ -25,7 +25,7 @@ export default withFragments({ } user { id - roles + role } } ${getSlotFragmentSpreads(slots, 'comment')} diff --git a/client/coral-admin/src/routes/Community/components/Table.js b/client/coral-admin/src/routes/Community/components/Table.js index 97b1db996..ac9d43a0e 100644 --- a/client/coral-admin/src/routes/Community/components/Table.js +++ b/client/coral-admin/src/routes/Community/components/Table.js @@ -66,7 +66,7 @@ const Table = ({users, setRole, onHeaderClickHandler, setUserBanStatus, viewUser setRole(row.id, role)}>