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/controllers/user-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const resendActivationEndPoint = async function (req) {
const activateUserAccountEndPoint = async function (req) {
const codeData = req.body;

return await UserService.activateUser(codeData, false);
await UserService.activateUser(codeData, false);
};

const userLogoutEndPoint = async function (req, user) {
Expand Down
2 changes: 2 additions & 0 deletions src/helpers/error-messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ module.exports = {
INVALID_CONTENT_TYPE: 'Invalid content type',
UPLOADED_FILE_NOT_FOUND: 'Uploaded image snapshot file not found',
REGISTRY_NOT_FOUND: 'Registry not found',
USER_ALREADY_ACTIVATED: 'User is already activated.',
USER_NOT_ACTIVATED_YET: 'User is not activated yet.',
CLI: {
INVALID_PORT_MAPPING: 'Port mapping parsing error. Please provide valid port mapping.',
INVALID_VOLUME_MAPPING: 'Volume mapping parsing error. Please provide valid volume mapping.',
Expand Down
12 changes: 12 additions & 0 deletions src/services/user-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ const activateUser = async function (codeData, isCLI, transaction) {
};

if (isCLI) {
const user = await UserManager.findOne({
id: codeData.userId
}, transaction);

if (user.emailActivated === true) {
throw new Error(ErrorMessages.USER_ALREADY_ACTIVATED)
}

await _updateUser(codeData.userId, updatedObj, transaction);
} else {
await Validator.validate(codeData, Validator.schemas.activateUser);
Expand Down Expand Up @@ -201,6 +209,10 @@ const list = async function (isCLI, transaction) {
};

const suspendUser = async function (user, isCLI, transaction) {
if (user.emailActivated === false) {
throw new Error(ErrorMessages.USER_NOT_ACTIVATED_YET)
}

const updatedObj = {
emailActivated: false
};
Expand Down