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
29 changes: 19 additions & 10 deletions lib/server/routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ UsersRouter.prototype.destroyUser = async function (req, res, next) {
};

await sendGridMail.send(emailData, false).catch(err=>{
log.error('failed to send deactivation email, reason: %s', err.message);
log.error('[USERS/DESTROY_USER]: failed to send deactivation email, reason: %s', err.message);

return next(new errors.InternalError(err.message));
});
Expand All @@ -408,8 +408,10 @@ UsersRouter.prototype.destroyUser = async function (req, res, next) {
res.status(200).send(user.toObject());
} catch (err) {
log.error(
'[USERS/DESTROY_USER]: Error while starting user deactivation: %s',
err.message
'[USERS/DESTROY_USER]: Error while starting user deactivation: %s, user: %s %s',
err.message,
req.user?.id,
req.user?.email
);

return next(new errors.InternalError(err.message));
Expand All @@ -426,7 +428,7 @@ UsersRouter.prototype.confirmDestroyUser = async function (req, res, next) {
const User = this.storage.models.User;
const Bucket = this.storage.models.Bucket;

log.debug('deactivating user account with token %s', req.params.token);
log.info('[USERS/CONFIRM_DESTROY]: deactivating user account with token %s', req.params.token);

try {
const user = await User.findOne({ deactivator: req.params.token });
Expand Down Expand Up @@ -461,9 +463,9 @@ UsersRouter.prototype.confirmDestroyUser = async function (req, res, next) {
UsersRouter.prototype.confirmDestroyUserStripe = async function (req, res, next) {
const self = this;
const stripeUtils = require('../stripeService');

let user = null;
try {
const user = await this.storage.models.User.findOne(
user = await this.storage.models.User.findOne(
{ deactivator: req.params.token });

if (!user) {
Expand All @@ -472,12 +474,18 @@ UsersRouter.prototype.confirmDestroyUserStripe = async function (req, res, next)
);
}

log.error(
'[USERS/STRIPE_CONFIRM_DESTROY]: User requested deactivation: %s',
user.email
);

const stripeUser = await stripeUtils
.customerExists(user._id)
.catch((err)=>{
log.error(
'Cannot determine customer exists on stripe: %s',
err.message
'[USERS/STRIPE_CONFIRM_DESTROY]: Cannot determine customer exists on stripe: %s, user email: %s',
err.message,
user?.email
);
throw new errors.InternalError('Error ocurred while deactivating user account');
});
Expand All @@ -502,8 +510,9 @@ UsersRouter.prototype.confirmDestroyUserStripe = async function (req, res, next)
return self.confirmDestroyUser(req, res, next);
} catch (err) {
log.error(
'[USERS/STRIPE_CONFIRM_DESTROY]: Error while deactivating user: %s',
err.message
'[USERS/STRIPE_CONFIRM_DESTROY]: Error while deactivating user: %s, user email: %s',
err.message,
user?.email
);

return next(
Expand Down
Loading
Loading