2022-09-24 06:47:37 +02:00
|
|
|
from pathlib import Path
|
|
|
|
from typing import List, Union
|
|
|
|
|
|
|
|
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
|
2022-09-24 06:47:37 +02:00
|
|
|
def get_dirs(self) -> List[Union[str, Path]]:
|
|
|
|
dirs = super().get_dirs()
|
|
|
|
# app_directories.Loader returns only a list of
|
|
|
|
# Path objects by calling get_app_template_dirs
|
|
|
|
two_factor_dirs: List[Union[str, Path]] = []
|
|
|
|
for d in dirs:
|
|
|
|
assert isinstance(d, Path)
|
|
|
|
if d.match("two_factor/*"):
|
|
|
|
two_factor_dirs.append(d)
|
|
|
|
return two_factor_dirs
|