mirror of
https://github.com/Sebclem/hassio-nextcloud-backup.git
synced 2024-11-09 19:12:58 +01:00
[Back] Check webdav cred in more places
This commit is contained in:
parent
35aaae183b
commit
b0070b1917
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -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(()=>{
|
||||
|
Loading…
Reference in New Issue
Block a user