Move logic out of User and Classes controllers

into RestWriter
This commit is contained in:
Arthur Cinader
2018-10-09 18:33:09 -07:00
parent b3b4461fe2
commit a0de2bcb6b
3 changed files with 21 additions and 24 deletions

View File

@@ -105,27 +105,14 @@ export class ClassesRouter extends PromiseRouter {
);
}
// always clear password reset token on email address change
beforeUpdate(req) {
const { body } = req;
if (this.className(req) === '_User' && 'email' in body) {
const { userController } = req.config;
return userController.constructor.addClearPasswordResetTokenToRestObject(
body
);
}
return body;
}
handleUpdate(req) {
const body = this.beforeUpdate(req);
const where = { objectId: req.params.objectId };
return rest.update(
req.config,
req.auth,
this.className(req),
where,
body,
req.body,
req.info.clientSDK
);
}