introduced new exception classes for structured error reporting

This commit is contained in:
zadam
2022-12-09 16:04:13 +01:00
parent eaf195e0c8
commit 342ae6e5e2
27 changed files with 123 additions and 64 deletions

View File

@@ -1,6 +1,7 @@
"use strict";
const passwordService = require('../../services/password');
const ValidationError = require("../../public/app/services/validation_error.js");
function changePassword(req) {
if (passwordService.isPasswordSet()) {
@@ -14,7 +15,7 @@ function changePassword(req) {
function resetPassword(req) {
// protection against accidental call (not a security measure)
if (req.query.really !== "yesIReallyWantToResetPasswordAndLoseAccessToMyProtectedNotes") {
return [400, "Incorrect password reset confirmation"];
throw new ValidationError("Incorrect password reset confirmation");
}
return passwordService.resetPassword();