mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
added validator to trim base url trailing slash (#2142)
This commit is contained in:
parent
d639bdcfe9
commit
c6d53fe8b1
@ -1,7 +1,7 @@
|
|||||||
import secrets
|
import secrets
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from pydantic import BaseSettings, NoneStr
|
from pydantic import BaseSettings, NoneStr, validator
|
||||||
|
|
||||||
from .db_providers import AbstractDBProvider, db_provider_factory
|
from .db_providers import AbstractDBProvider, db_provider_factory
|
||||||
|
|
||||||
@ -25,12 +25,17 @@ def determine_secrets(data_dir: Path, production: bool) -> str:
|
|||||||
class AppSettings(BaseSettings):
|
class AppSettings(BaseSettings):
|
||||||
PRODUCTION: bool
|
PRODUCTION: bool
|
||||||
BASE_URL: str = "http://localhost:8080"
|
BASE_URL: str = "http://localhost:8080"
|
||||||
|
"""trailing slashes are trimmed (ex. `http://localhost:8080/` becomes ``http://localhost:8080`)"""
|
||||||
|
|
||||||
IS_DEMO: bool = False
|
IS_DEMO: bool = False
|
||||||
API_PORT: int = 9000
|
API_PORT: int = 9000
|
||||||
API_DOCS: bool = True
|
API_DOCS: bool = True
|
||||||
TOKEN_TIME: int = 48 # Time in Hours
|
TOKEN_TIME: int = 48
|
||||||
|
"""time in hours"""
|
||||||
|
|
||||||
SECRET: str
|
SECRET: str
|
||||||
LOG_LEVEL: str = "INFO" # Corresponds to standard Python log levels.
|
LOG_LEVEL: str = "INFO"
|
||||||
|
"""corresponds to standard Python log levels"""
|
||||||
|
|
||||||
GIT_COMMIT_HASH: str = "unknown"
|
GIT_COMMIT_HASH: str = "unknown"
|
||||||
|
|
||||||
@ -40,7 +45,15 @@ class AppSettings(BaseSettings):
|
|||||||
# Security Configuration
|
# Security Configuration
|
||||||
|
|
||||||
SECURITY_MAX_LOGIN_ATTEMPTS: int = 5
|
SECURITY_MAX_LOGIN_ATTEMPTS: int = 5
|
||||||
SECURITY_USER_LOCKOUT_TIME: int = 24 # Time in Hours
|
SECURITY_USER_LOCKOUT_TIME: int = 24
|
||||||
|
"time in hours"
|
||||||
|
|
||||||
|
@validator("BASE_URL")
|
||||||
|
def remove_trailing_slash(cls, v: str) -> str:
|
||||||
|
if v and v[-1] == "/":
|
||||||
|
return v[:-1]
|
||||||
|
|
||||||
|
return v
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def DOCS_URL(self) -> str | None:
|
def DOCS_URL(self) -> str | None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user