diff --git a/nextcloud_backup/backend/src/routes/config.ts b/nextcloud_backup/backend/src/routes/config.ts index 5f1db41..4fde6b2 100644 --- a/nextcloud_backup/backend/src/routes/config.ts +++ b/nextcloud_backup/backend/src/routes/config.ts @@ -5,6 +5,7 @@ import { validateBackupConfig, } from "../services/backupConfigService.js"; import { getWebdavConfig, saveWebdavConfig, validateWebdavConfig } from "../services/webdavConfigService.js"; +import { checkWebdavLogin } from "../services/webdavService.js"; const configRouter = express.Router(); @@ -31,6 +32,9 @@ configRouter.get("/webdav", (req, res, next) => { configRouter.put("/webdav", (req, res, next) => { validateWebdavConfig(req.body) + .then(() => { + return checkWebdavLogin(req.body, true) + }) .then(() => { saveWebdavConfig(req.body); res.status(204); @@ -38,7 +42,7 @@ configRouter.put("/webdav", (req, res, next) => { }) .catch((error) => { res.status(400); - res.json(error.details); + res.json(error.details ? error.details : error); }); }); diff --git a/nextcloud_backup/backend/src/routes/webdav.ts b/nextcloud_backup/backend/src/routes/webdav.ts index b31734c..cad8eeb 100644 --- a/nextcloud_backup/backend/src/routes/webdav.ts +++ b/nextcloud_backup/backend/src/routes/webdav.ts @@ -16,6 +16,9 @@ webdavRouter.get("/backup/auto", (req, res, next) => { const config = getWebdavConfig(); const backupConf = getBackupConfig(); validateWebdavConfig(config) + .then(() => { + return webdavService.checkWebdavLogin(config); + }) .then(async () => { const value = await webdavService .getBackups(pathTools.auto, config, backupConf.nameTemplate); @@ -31,6 +34,9 @@ webdavRouter.get("/backup/manual", (req, res, next) => { const config = getWebdavConfig(); const backupConf = getBackupConfig(); validateWebdavConfig(config) + .then(() => { + return webdavService.checkWebdavLogin(config); + }) .then(async () => { const value = await webdavService .getBackups(pathTools.manual, config, backupConf.nameTemplate); @@ -49,6 +55,9 @@ webdavRouter.delete("/", (req, res, next) => { validateWebdavConfig(config).then(() => { validator .validateAsync(body) + .then(() => { + return webdavService.checkWebdavLogin(config); + }) .then(() => { webdavService.deleteBackup(body.path, config) .then(()=>{