Skip to content

Commit

Permalink
remove logs from user file, update failing test due to hard coded date
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard-Pentecost committed Jul 21, 2022
1 parent 29373e6 commit 182b2ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
12 changes: 1 addition & 11 deletions server/routes/accounts/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,7 @@ const finishAddUser = async (req, res) => {
};

const deleteUser = async (req, res) => {
console.log('********************** user.js accounts/deleteUser ******************************');

const userId = req.params.userid;
console.log('##### deleteUser - userId:', userId);

const uuidRegex = /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/;
if (!uuidRegex.test(userId.toUpperCase())) {
Expand All @@ -638,30 +635,23 @@ const deleteUser = async (req, res) => {
const thisUser = new User.User(userId);

try {
console.log('##### deleteUser - inside try');
if (await thisUser.restore(userId, null, false)) {
console.log('##### deleteUser - restore succeeded');
if (thisUser.username && thisUser.username == req.username) {
return res.status(400).send('Cannot delete own user account');
}

if (thisUser._isPrimary) {
console.log('##### deleteUser - user is primary');
return res.status(400).send('Cannot delete primary account');
}

console.log('restored about to delete');
await thisUser.delete(req.username);
console.log('##### deleteUser - delete completed');

return res.status(204).send();
} else {
console.log('##### deleteUser - restore failed');
console.log('404 not found that user');
return res.status(404).send('Not Found');
}
} catch (err) {
console.log('##### deleteUser - error');
console.log(err);
const thisError = new User.UserExceptions.UserRestoreException(
thisUser.id,
thisUser.uid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ describe('NewTrainingAndQualificationsRecordComponent', () => {

const yesterday = new Date();
const tomorrow = new Date();
const activeDate = new Date();

yesterday.setDate(yesterday.getDate() - 1);
tomorrow.setDate(tomorrow.getDate() + 1);
activeDate.setDate(activeDate.getDate() + 93); // 3 months in the future

async function setup(
otherJob = false,
Expand Down Expand Up @@ -77,10 +79,10 @@ describe('NewTrainingAndQualificationsRecordComponent', () => {
{
accredited: true,
completed: new Date('10/20/2021'),
expires: new Date('10/20/2022'),
expires: activeDate,
title: 'Health training',
trainingCategory: { id: 1, category: 'Health' },
trainingStatus: 3,
trainingStatus: 0,
uid: 'someHealthuid',
},
],
Expand Down

0 comments on commit 182b2ff

Please sign in to comment.