2022-09-24 06:47:37 +02:00
|
|
|
from pathlib import Path
|
2024-07-12 02:30:17 +02:00
|
|
|
from typing import Union
|
2022-09-24 06:47:37 +02:00
|
|
|
|
|
|
|
from django.template.loaders import app_directories
|
2023-10-12 19:43:45 +02:00
|
|
|
from typing_extensions import override
|
2022-09-24 06:47:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
class TwoFactorLoader(app_directories.Loader):
|
2023-10-12 19:43:45 +02:00
|
|
|
@override
|
2024-07-12 02:30:17 +02:00
|
|
|
def get_dirs(self) -> list[Union[str, Path]]:
|
2022-09-24 06:47:37 +02:00
|
|
|
dirs = super().get_dirs()
|
|
|
|
# app_directories.Loader returns only a list of
|
|
|
|
# Path objects by calling get_app_template_dirs
|
2024-07-12 02:30:17 +02:00
|
|
|
two_factor_dirs: list[Union[str, Path]] = []
|
2022-09-24 06:47:37 +02:00
|
|
|
for d in dirs:
|
|
|
|
assert isinstance(d, Path)
|
|
|
|
if d.match("two_factor/*"):
|
|
|
|
two_factor_dirs.append(d)
|
|
|
|
return two_factor_dirs
|