from django.contrib.auth.decorators import login_required
from django.urls import include, path

from newsreader.accounts.views import (
    FaviconRedirectView,
    LoginView,
    LogoutView,
    PasswordChangeView,
    PasswordResetCompleteView,
    PasswordResetConfirmView,
    PasswordResetDoneView,
    PasswordResetView,
    SettingsView,
)


settings_patterns = [
    # Misc
    path("favicon/", login_required(FaviconRedirectView.as_view()), name="favicon"),
    path("", login_required(SettingsView.as_view()), name="home"),
]

urlpatterns = [
    # Auth
    path("login/", LoginView.as_view(), name="login"),
    path("logout/", LogoutView.as_view(), name="logout"),
    # Password
    path("password-reset/", PasswordResetView.as_view(), name="password-reset"),
    path(
        "password-reset/done/",
        PasswordResetDoneView.as_view(),
        name="password-reset-done",
    ),
    path(
        "password-reset/<uidb64>/<token>/",
        PasswordResetConfirmView.as_view(),
        name="password-reset-confirm",
    ),
    path(
        "password-reset/done/",
        PasswordResetCompleteView.as_view(),
        name="password-reset-complete",
    ),
    path(
        "password-change/",
        login_required(PasswordChangeView.as_view()),
        name="password-change",
    ),
    # Settings
    path("settings/", include((settings_patterns, "settings"))),
]
