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

#166816124 Super admins can create users #17

Merged
merged 1 commit into from
Jul 8, 2019

Conversation

dharmykoya
Copy link
Contributor

@dharmykoya dharmykoya commented Jul 5, 2019

What does this PR do?

Allowing super admins to create users.

Description of Task to be completed?

  • To write Test for all the functions
  • To allow superAdmin to create users
  • To allow superAdmin change users roleType
  • To allow admins to delete users
  • To allow admins to update users information
  • To setup pre-commit hooks

How should this be manually tested?

N/A

Any background context you want to provide?

N/A

What are the relevant pivotal tracker stories?

#166816124

Screenshots (if appropriate)

N/A

Questions:

N/A

Copy link

@hound hound bot left a comment

Choose a reason for hiding this comment

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

Some files could not be reviewed due to errors:

.eslintrc:
.eslintrc:
	Environment key "jest/globals" is unknown

Error: .eslintrc:
at Object.keys.forEach.env (/home/linters/app/versions/eslint-4.18.2/node_modules/eslint/lib/config/config-validator.js:144:19)
at Array.forEach ()
at validateEnvironment (/home/linters/app/versions/eslint-4.18.2/node_modules/eslint/lib/config/config-validator.js:140:30)
at Object.validate (/home/linters/app/versions/eslint-4.18.2/node_modules/eslint/lib/config/config-validator.js:240:5)
at loadFromDisk (/home/linters/app/versions/eslint-4.18.2/node_modules/eslint/lib/config/config-file.js:516:19)
at Object.load (/home/linters/app/versions/eslint-4.18.2/node_modules/eslint/lib/config/config-file.js:559:20)
at Config.getLocalConfigHierarchy (/home/linters/app/versions/eslint-4.18.2/node_modules/eslint/lib/config.js:227:44)
at Config.getConfigHierarchy (/home/linters/app/versions/eslint-4.18.2/node_modules/eslint/lib/config.js:179:43)
at Config.getConfigVector (/home/linters/app/versions/eslint-4.18.2/node_modules/eslint/lib/config.js:286:21)
at Config.getConfig (/home/linters/app/versions/eslint-4.18.2/node_modules/eslint/lib/config.js:329:29)

@dharmykoya dharmykoya changed the title #166816124 f #166816124 Super admins can create users Jul 5, 2019
Copy link
Contributor

@tunedev tunedev left a comment

Choose a reason for hiding this comment

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

Good one @dharmykoya, LGTM.

@fxola
Copy link
Contributor

fxola commented Jul 5, 2019

LGTM

1 similar comment
@halimahO
Copy link
Contributor

halimahO commented Jul 6, 2019

LGTM

allowNull: true
allowNull: true,
validate: {
isAlpha: {
Copy link
Contributor

Choose a reason for hiding this comment

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

make this alphanumberic

const admin =
request.user.roleType === 'super_admin' ||
request.user.roleType === 'admin';
if (!admin) {
Copy link
Contributor

Choose a reason for hiding this comment

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

put the condition in the if bracket.

To allow superAdmin create users
To allow superAdmin change users roleType
To allow admins delete users
To allow admins update users information
To setup precommit hooks
[#166816124]
@dharmykoya dharmykoya force-pushed the ft-admin-create-user-166816124 branch from 3b83038 to 952feb6 Compare July 8, 2019 11:22
.isNumeric()
.not()
.matches('[-, +, %]')
.withMessage('User ID must be a number')
Copy link

Choose a reason for hiding this comment

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

Replace 'User·ID·must·be·a·number' with "User·ID·must·be·a·number" prettier/prettier

param('userId')
.isNumeric()
.not()
.matches('[-, +, %]')
Copy link

Choose a reason for hiding this comment

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

Replace '[-,·+,·%]' with "[-,·+,·%]" prettier/prettier


case 'userId':
return [
param('userId')
Copy link

Choose a reason for hiding this comment

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

Replace 'userId' with "userId" prettier/prettier

.withMessage('Please select an appropriate role type')
];

case 'userId':
Copy link

Choose a reason for hiding this comment

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

Replace 'userId' with "userId" prettier/prettier

return [
check('role')
.isIn(['admin', 'super_admin'])
.withMessage('Please select an appropriate role type')
Copy link

Choose a reason for hiding this comment

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

Replace 'Please·select·an·appropriate·role·type' with "Please·select·an·appropriate·role·type" prettier/prettier

const confirmEmailCode = crypto.randomBytes(16).toString('hex');
return User.create({
firstName: 'Damilola',
lastName: 'Adekoya',
Copy link

Choose a reason for hiding this comment

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

Replace 'Adekoya' with "Adekoya" prettier/prettier

const hashedPassword = bcrypt.hashSync('author40', 10);
const confirmEmailCode = crypto.randomBytes(16).toString('hex');
return User.create({
firstName: 'Damilola',
Copy link

Choose a reason for hiding this comment

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

Replace 'Damilola' with "Damilola" prettier/prettier

@@ -32,6 +48,19 @@ export const createUser = user => {
});
};

export const createSuperAdmin = () => {
const hashedPassword = bcrypt.hashSync('author40', 10);
const confirmEmailCode = crypto.randomBytes(16).toString('hex');
Copy link

Choose a reason for hiding this comment

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

Replace 'hex' with "hex" prettier/prettier

@@ -32,6 +48,19 @@ export const createUser = user => {
});
};

export const createSuperAdmin = () => {
const hashedPassword = bcrypt.hashSync('author40', 10);
Copy link

Choose a reason for hiding this comment

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

Replace 'author40' with "author40" prettier/prettier

lastName: faker.name.lastName(),
email: faker.internet.email(),
password: 'Author40',
role: 'admin'
Copy link

Choose a reason for hiding this comment

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

Replace 'admin' with "admin" prettier/prettier

@nedemenang nedemenang merged commit 3a9ef89 into develop Jul 8, 2019
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.

None yet

5 participants