Add invite endpoint, add validation to invit endpoint
This commit is contained in:
1 parent
52ac2792c0
commit
428e018aff
4 files changed
+55
-1875
No files matched your search
@@ -1,5 +1,17 @@
|
||||
const joi = require("joi");
|
||||
|
||||
//****************************************
|
||||
// Custom Validators
|
||||
//****************************************
|
||||
|
||||
const roleValidatior = (role) => (value, helpers) => {
|
||||
console.log(role);
|
||||
if (!value.includes(role)) {
|
||||
throw new joi.ValidationError(`You do not have ${role} authorization`);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
//****************************************
|
||||
// Auth
|
||||
//****************************************
|
||||
@@ -87,6 +99,20 @@ const deleteUserParamValidation = joi.object({
|
||||
email: joi.string().email().required(),
|
||||
});
|
||||
|
||||
const inviteRoleValidation = joi.object({
|
||||
roles: joi.custom(roleValidatior("admin")).required(),
|
||||
});
|
||||
|
||||
const inviteBodyValidation = joi.object({
|
||||
email: joi.string().trim().email().required().messages({
|
||||
"string.empty": "Email is required",
|
||||
"string.email": "Must be a valid email address",
|
||||
}),
|
||||
role: joi.string().required().messages({
|
||||
"string.empty": "Role is required",
|
||||
}),
|
||||
});
|
||||
|
||||
//****************************************
|
||||
// Monitors
|
||||
//****************************************
|
||||
@@ -195,11 +221,14 @@ const deletePageSpeedCheckParamValidation = joi.object({
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
roleValidatior,
|
||||
loginValidation,
|
||||
registerValidation,
|
||||
recoveryValidation,
|
||||
recoveryTokenValidation,
|
||||
newPasswordValidation,
|
||||
inviteRoleValidation,
|
||||
inviteBodyValidation,
|
||||
getMonitorByIdValidation,
|
||||
getMonitorsByUserIdValidation,
|
||||
monitorValidation,
|
||||
|
||||
Reference in new issue
Block a user