add time_zone setter route

This commit is contained in:
Girish Ramakrishnan
2016-06-02 13:36:47 -07:00
parent 54ead09aac
commit 65261dc4d5
3 changed files with 18 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ exports = module.exports = {
setBackupConfig: setBackupConfig,
getTimeZone: getTimeZone,
setTimeZone: setTimeZone,
setCertificate: setCertificate,
setAdminCertificate: setAdminCertificate
@@ -81,6 +82,19 @@ function getTimeZone(req, res, next) {
});
}
function setTimeZone(req, res, next) {
assert.strictEqual(typeof req.body, 'object');
if (typeof req.body.timeZone !== 'string') return next(new HttpError(400, 'timeZone is required'));
settings.setTimeZone(req.body.timeZone, function (error) {
if (error && error.reason === SettingsError.BAD_FIELD) return next(new HttpError(400, error.message));
if (error) return next(new HttpError(500, error));
next(new HttpSuccess(200));
});
}
function setCloudronAvatar(req, res, next) {
assert.strictEqual(typeof req.files, 'object');