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
2 changes: 1 addition & 1 deletion src/constants/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
'/user/v1/user-role/default',
],
notificationEmailType: 'email',
accessTokenExpiry: `${process.env.ACCESS_TOKEN_EXPIRY}d`,
accessTokenExpiry: process.env.ACCESS_TOKEN_EXPIRY,
refreshTokenExpiry: `${process.env.REFRESH_TOKEN_EXPIRY}d`,
refreshTokenExpiryInMs: Number(process.env.REFRESH_TOKEN_EXPIRY) * 24 * 60 * 60 * 1000,
refreshTokenLimit: 3,
Expand Down
15 changes: 13 additions & 2 deletions src/envVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ let enviromentVariables = {
optional: process.env.CLOUD_STORAGE === 'AZURE' ? false : true,
},
ACCESS_TOKEN_EXPIRY: {
message: 'Required access token expiry in days',
message: 'Required access token expiry',
optional: false,
},
REFRESH_TOKEN_EXPIRY: {
message: 'Required refresh token expiry in days',
message: 'Required refresh token expiry',
optional: false,
},
API_DOC_URL: {
Expand Down Expand Up @@ -241,6 +241,17 @@ let enviromentVariables = {
optional: true,
default: '*',
},
PASSWORD_POLICY_REGEX: {
message: 'Required password policy',
optional: true,
default: '/^(?=.*[A-Z])(?=.*d)(?=.*[!@#$%^&*()_+{}|:<>?~`-=[];,./])[^ ]{11,}$/',
},
PASSWORD_POLICY_MESSAGE: {
message: 'Required password policy message',
optional: true,
default:
'Password must have at least one uppercase letter, one number, one special character, and be at least 10 characters long',
},
DOWNLOAD_URL_EXPIRATION_DURATION: {
message: 'Required downloadable url expiration time',
optional: true,
Expand Down
4 changes: 3 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,7 @@
"ROLES_HAS_EMPTY_LIST": "Empty roles list",
"COLUMN_DOES_NOT_EXISTS": "Role column does not exists",
"PERMISSION_DENIED": "You do not have the required permissions to access this resource. Please contact your administrator for assistance.",
"RELATED_ORG_REMOVAL_FAILED": "Requested organization not related the organization. Please check the values."
"RELATED_ORG_REMOVAL_FAILED": "Requested organization not related the organization. Please check the values.",
"INAVLID_ORG_ROLE_REQ": "Invalid organisation request"

}
13 changes: 13 additions & 0 deletions src/services/org-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,19 @@ module.exports = class OrgAdminHelper {
const requestId = bodyData.request_id
delete bodyData.request_id

const requestDetail = await orgRoleReqQueries.requestDetails({
id: requestId,
organization_id: tokenInformation.organization_id,
})

if (requestDetail.status !== common.REQUESTED_STATUS) {
return responses.failureResponse({
message: 'INAVLID_ORG_ROLE_REQ',
statusCode: httpStatusCode.bad_request,
responseCode: 'CLIENT_ERROR',
})
}

bodyData.handled_by = tokenInformation.id
const rowsAffected = await orgRoleReqQueries.update(
{ id: requestId, organization_id: tokenInformation.organization_id },
Expand Down
16 changes: 14 additions & 2 deletions src/validators/v1/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ module.exports = {
.withMessage('email is invalid')
.normalizeEmail({ gmail_remove_dots: false })

req.checkBody('password').trim().notEmpty().withMessage('password field is empty')
req.checkBody('password')
.notEmpty()
.withMessage('Password field is empty')
.matches(process.env.PASSWORD_POLICY_REGEX)
.withMessage(process.env.PASSWORD_POLICY_MESSAGE)
.custom((value) => !/\s/.test(value))
.withMessage('Password cannot contain spaces')

if (req.body.role) {
req.checkBody('role').trim().not().isIn([common.ADMIN_ROLE]).withMessage("User does't have admin access")
Expand Down Expand Up @@ -64,7 +70,13 @@ module.exports = {

resetPassword: (req) => {
req.checkBody('email').notEmpty().withMessage('email field is empty').isEmail().withMessage('email is invalid')
req.checkBody('password').notEmpty().withMessage('password field is empty')
req.checkBody('password')
.notEmpty()
.withMessage('Password field is empty')
.matches(process.env.PASSWORD_POLICY_REGEX)
.withMessage(process.env.PASSWORD_POLICY_MESSAGE)
.custom((value) => !/\s/.test(value))
.withMessage('Password cannot contain spaces')

req.checkBody('otp')
.notEmpty()
Expand Down
8 changes: 7 additions & 1 deletion src/validators/v1/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ module.exports = {
.withMessage('email is invalid')
.normalizeEmail()

req.checkBody('password').trim().notEmpty().withMessage('password field is empty')
req.checkBody('password')
.notEmpty()
.withMessage('Password field is empty')
.matches(process.env.PASSWORD_POLICY_REGEX)
.withMessage(process.env.PASSWORD_POLICY_MESSAGE)
.custom((value) => !/\s/.test(value))
.withMessage('Password cannot contain spaces')
},

login: (req) => {
Expand Down