mirror of
https://github.com/Sebclem/hassio-nextcloud-backup.git
synced 2024-11-09 02:52:58 +01:00
[Back] Check webdav cred in more places
This commit is contained in:
parent
28225dbf67
commit
10fcb94962
@ -5,6 +5,7 @@ import {
|
|||||||
validateBackupConfig,
|
validateBackupConfig,
|
||||||
} from "../services/backupConfigService.js";
|
} from "../services/backupConfigService.js";
|
||||||
import { getWebdavConfig, saveWebdavConfig, validateWebdavConfig } from "../services/webdavConfigService.js";
|
import { getWebdavConfig, saveWebdavConfig, validateWebdavConfig } from "../services/webdavConfigService.js";
|
||||||
|
import { checkWebdavLogin } from "../services/webdavService.js";
|
||||||
|
|
||||||
const configRouter = express.Router();
|
const configRouter = express.Router();
|
||||||
|
|
||||||
@ -31,6 +32,9 @@ configRouter.get("/webdav", (req, res, next) => {
|
|||||||
|
|
||||||
configRouter.put("/webdav", (req, res, next) => {
|
configRouter.put("/webdav", (req, res, next) => {
|
||||||
validateWebdavConfig(req.body)
|
validateWebdavConfig(req.body)
|
||||||
|
.then(() => {
|
||||||
|
return checkWebdavLogin(req.body, true)
|
||||||
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
saveWebdavConfig(req.body);
|
saveWebdavConfig(req.body);
|
||||||
res.status(204);
|
res.status(204);
|
||||||
@ -38,7 +42,7 @@ configRouter.put("/webdav", (req, res, next) => {
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
res.status(400);
|
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 config = getWebdavConfig();
|
||||||
const backupConf = getBackupConfig();
|
const backupConf = getBackupConfig();
|
||||||
validateWebdavConfig(config)
|
validateWebdavConfig(config)
|
||||||
|
.then(() => {
|
||||||
|
return webdavService.checkWebdavLogin(config);
|
||||||
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
const value = await webdavService
|
const value = await webdavService
|
||||||
.getBackups(pathTools.auto, config, backupConf.nameTemplate);
|
.getBackups(pathTools.auto, config, backupConf.nameTemplate);
|
||||||
@ -31,6 +34,9 @@ webdavRouter.get("/backup/manual", (req, res, next) => {
|
|||||||
const config = getWebdavConfig();
|
const config = getWebdavConfig();
|
||||||
const backupConf = getBackupConfig();
|
const backupConf = getBackupConfig();
|
||||||
validateWebdavConfig(config)
|
validateWebdavConfig(config)
|
||||||
|
.then(() => {
|
||||||
|
return webdavService.checkWebdavLogin(config);
|
||||||
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
const value = await webdavService
|
const value = await webdavService
|
||||||
.getBackups(pathTools.manual, config, backupConf.nameTemplate);
|
.getBackups(pathTools.manual, config, backupConf.nameTemplate);
|
||||||
@ -49,6 +55,9 @@ webdavRouter.delete("/", (req, res, next) => {
|
|||||||
validateWebdavConfig(config).then(() => {
|
validateWebdavConfig(config).then(() => {
|
||||||
validator
|
validator
|
||||||
.validateAsync(body)
|
.validateAsync(body)
|
||||||
|
.then(() => {
|
||||||
|
return webdavService.checkWebdavLogin(config);
|
||||||
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
webdavService.deleteBackup(body.path, config)
|
webdavService.deleteBackup(body.path, config)
|
||||||
.then(()=>{
|
.then(()=>{
|
||||||
|
Loading…
Reference in New Issue
Block a user