mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-03 14:33:11 -05:00
add TOKEN_TIME and DEFAULT_EMAIL
This commit is contained in:
@@ -117,8 +117,11 @@ class AppSettings(BaseSettings):
|
||||
return app_dirs.SQLITE_DIR.joinpath(f"mealie_{DB_VERSION}.sqlite")
|
||||
|
||||
DEFAULT_GROUP: str = "Home"
|
||||
DEFAULT_EMAIL: str = "changeme@email.com"
|
||||
DEFAULT_PASSWORD: str = "MyPassword"
|
||||
|
||||
TOKEN_TIME: int = 2 # Time in Hours
|
||||
|
||||
# Not Used!
|
||||
SFTP_USERNAME: Optional[str]
|
||||
SFTP_PASSWORD: Optional[str]
|
||||
|
||||
@@ -13,10 +13,10 @@ ALGORITHM = "HS256"
|
||||
|
||||
def create_access_token(data: dict(), expires_delta: timedelta = None) -> str:
|
||||
to_encode = data.copy()
|
||||
if expires_delta:
|
||||
expire = datetime.utcnow() + expires_delta
|
||||
else:
|
||||
expire = datetime.utcnow() + timedelta(minutes=120)
|
||||
expires_delta = expires_delta or timedelta(hours=settings.TOKEN_TIME)
|
||||
|
||||
expire = datetime.utcnow() + expires_delta
|
||||
|
||||
to_encode.update({"exp": expire})
|
||||
return jwt.encode(to_encode, settings.SECRET, algorithm=ALGORITHM)
|
||||
|
||||
@@ -27,7 +27,7 @@ def create_file_token(file_path: Path) -> bool:
|
||||
|
||||
|
||||
def authenticate_user(session, email: str, password: str) -> UserInDB:
|
||||
user: UserInDB = db.users.get(session, email, "email")
|
||||
user: UserInDB = db.users.get(session, email, "email", any_case=True)
|
||||
if not user:
|
||||
return False
|
||||
if not verify_password(password, user.password):
|
||||
|
||||
Reference in New Issue
Block a user