from django.conf import settings
from django.urls import path

from .views.login import (ActivateView, ChangePasswordView, CustomLogoutView,
                          CustomPasswordResetConfirmView, ForgotPasswordView,
                          LoginView, RegisterView)
from .views.user_api import api_auth_status, api_logout
from .views.users_index import UserIndexView

app_name = 'users'
urlpatterns = [
    path('register/', RegisterView.as_view(), name='register'),
    path('activate/<uidb64>/<token>/', ActivateView.as_view(),
         name='activate'),
    path('login/', LoginView.as_view(), name='login'),
    path('forgot-password/',
         ForgotPasswordView.as_view(),
         name='forgot_password'),
    path('reset-password/<uidb64>/<token>/',
         CustomPasswordResetConfirmView.as_view(),
         name='password_reset_confirm'),
    path('index/', UserIndexView.as_view(), name='user_index'),
    path('logout/', CustomLogoutView.as_view(), name='logout'),
    path('change-password/',
         ChangePasswordView.as_view(),
         name='change_password'),
    path('api/auth/status/', api_auth_status, name='api_auth_status'),
    path('api/auth/logout/', api_logout, name='api_logout'),
]
try:
    registe_config = settings.GLOBAL_CONFIG.get('AuxiliaryConfig', {}).get(
        'allow_registration', True)
except:
    registe_config = True
if registe_config:
    urlpatterns += [
        path('register/', RegisterView.as_view(), name='register'),
    ]
