1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-23 00:16:25 +01:00
unleash.unleash/src/lib/error/owasp-validation-error.ts
Christopher Kolstad b55c85783b
Reset token (#786)
feat: Add Reset token functionality

This allows admin users to create a reset token for other users. Thus allowing resetting their password.

Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>

fixes: #778
2021-04-16 15:29:23 +02:00

30 lines
756 B
TypeScript

import { TestResult } from 'owasp-password-strength-test';
class OwaspValidationError extends Error {
private errors: string[];
constructor(testResult: TestResult) {
super(testResult.errors[0]);
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.errors = testResult.errors;
}
toJSON(): any {
const obj = {
isJoi: true,
name: this.constructor.name,
details: [
{
validationErrors: this.errors,
message: this.errors[0],
},
],
};
return obj;
}
}
export default OwaspValidationError;
module.exports = OwaspValidationError;