-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
There was a problem hiding this 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 unknownError: .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)
There was a problem hiding this 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.
LGTM |
1 similar comment
LGTM |
src/db/models/user.js
Outdated
allowNull: true | ||
allowNull: true, | ||
validate: { | ||
isAlpha: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this alphanumberic
src/middlewares/auth.middleware.js
Outdated
const admin = | ||
request.user.roleType === 'super_admin' || | ||
request.user.roleType === 'admin'; | ||
if (!admin) { |
There was a problem hiding this comment.
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]
3b83038
to
952feb6
Compare
.isNumeric() | ||
.not() | ||
.matches('[-, +, %]') | ||
.withMessage('User ID must be a number') |
There was a problem hiding this comment.
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('[-, +, %]') |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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': |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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
What does this PR do?
Allowing super admins to create users.
Description of Task to be completed?
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