"""
Re-definition of Django's auth URLs.

This is done for convenience. It allows us to save all registration and auth
related templates in the same `/templates/registration/` folder.

"""
from django.conf.urls import url, patterns
from django.contrib.auth import views as auth_views

from .backends.default.urls import urlpatterns as default_urlpatterns
from .forms import EmailAuthenticationForm, AccountPasswordResetForm, AccountSetPasswordForm, AccountPasswordChangeForm, AccountPasswordSetForm
from .views import account, login_remember_me, update_details, sign_in_token
from .decorators import no_password_required


urlpatterns = default_urlpatterns + patterns(
    '',
    url(r'^$', account, name="my_account"),
    url(r'update-details/$', update_details, name="account_update_details"),
    url(
        r'^login/$',
        login_remember_me,
        {'template_name': 'account/login.html',
         'authentication_form': EmailAuthenticationForm, },
        name='account_login',
    ),
    url(
        r'^logout/$',
        auth_views.logout,
        {'template_name': 'account/logout.html'},
        name='account_logout',
    ),
    url(
        r'^password/change/$',
        auth_views.password_change,
        {'template_name': 'account/password_change_form.html',
            'password_change_form':AccountPasswordChangeForm},
        name='account_password_change',
    ),
    url(
        r'^password/set/$',
        no_password_required(auth_views.password_change),
        {'template_name': 'account/password_set_form.html',
            'password_change_form':AccountPasswordSetForm},
        name='account_password_set',
    ),
    url(
        r'^password/change/done/$',
        auth_views.password_change_done,
        {'template_name': 'account/password_change_done.html'},
        name='password_change_done',
    ),
    url(
        r'^password/reset/$',
        auth_views.password_reset,
        {'template_name': 'account/password_reset_form.html',
            'password_reset_form':AccountPasswordResetForm,
            'email_template_name':'account/password_reset_email.html',
            'subject_template_name':'account/password_reset_subject.txt',},
        name='account_password_reset',
    ),
    url(
        r'^password/reset/confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
        auth_views.password_reset_confirm,
        {'template_name': 'account/password_reset_confirm.html',
            'set_password_form':AccountSetPasswordForm},
        name='password_reset_confirm',
    ),
    url(
        r'^password/reset/complete/$',
        auth_views.password_reset_complete,
        {'template_name': 'account/password_reset_complete.html'},  # NOQA
        name='password_reset_complete',
    ),
    url(
        r'^password/reset/done/$',
        auth_views.password_reset_done,
        {'template_name': 'account/password_reset_done.html'},
        name='password_reset_done',
    ),
    url(r'^sign-in-token/(?P<uuid>[-\w]+)/$',
        sign_in_token,
        name='sign_in_token'),
)
