Add password error to not display password in plain text

This commit is contained in:
amcmanu3 2024-06-13 17:09:00 -04:00
parent d8ad8f5e09
commit f5874d701a
3 changed files with 13 additions and 2 deletions

View File

@ -55,6 +55,7 @@ class UsersController:
"minLength": self.helper.minimum_password_length,
"examples": ["crafty"],
"title": "Password",
"error": "passLength",
},
"email": {
"type": "string",

View File

@ -2,6 +2,7 @@ import logging
import json
from jsonschema import validate
from jsonschema.exceptions import ValidationError
from app.classes.shared.translation import Translation
from app.classes.models.crafty_permissions import EnumPermissionsCrafty
from app.classes.models.roles import Roles, HelperRoles
from app.classes.models.users import PUBLIC_USER_ATTRS
@ -54,6 +55,7 @@ class ApiUsersIndexHandler(BaseApiHandler):
)
def post(self):
self.translator = Translation(self.helper)
new_user_schema = {
"type": "object",
"properties": {
@ -87,12 +89,17 @@ class ApiUsersIndexHandler(BaseApiHandler):
try:
validate(data, new_user_schema)
except ValidationError as e:
err = self.translator.translate(
"validators",
e.schema["error"],
self.controller.users.get_user_lang_by_id(auth_data[4]["user_id"]),
)
return self.finish_json(
400,
{
"status": "error",
"error": "INVALID_JSON_SCHEMA",
"error_data": str(e),
"error_data": f"{str(err)}",
},
)
username = data["username"]

View File

@ -650,6 +650,9 @@
"userTheme": "UI Theme",
"uses": "Number of uses allowed (-1==No Limit)"
},
"validators": {
"passLength": "Password Too Short. Minimum Length: 8"
},
"webhooks": {
"areYouSureDel": "Are you sure you want to delete this webhook?",
"areYouSureRun": "Are you sure you want to test this webhook?",
@ -675,4 +678,4 @@
"webhook_body": "Webhook Body",
"webhooks": "Webhooks"
}
}
}