| 1 |
from django.conf import settings |
| 2 |
from django.urls import path, re_path |
| 3 |
|
| 4 |
from allauth import app_settings as allauth_app_settings |
| 5 |
from allauth.account import app_settings |
| 6 |
|
| 7 |
from . import views |
| 8 |
|
| 9 |
|
| 10 |
urlpatterns = [ |
| 11 |
path("login/", views.login, name="account_login"), |
| 12 |
path("logout/", views.logout, name="account_logout"), |
| 13 |
path("inactive/", views.account_inactive, name="account_inactive"), |
| 14 |
] |
| 15 |
|
| 16 |
if not allauth_app_settings.SOCIALACCOUNT_ONLY: |
| 17 |
urlpatterns.extend( |
| 18 |
[ |
| 19 |
path("signup/", views.signup, name="account_signup"), |
| 20 |
path( |
| 21 |
"reauthenticate/", views.reauthenticate, name="account_reauthenticate" |
| 22 |
), |
| 23 |
# Email |
| 24 |
path("email/", views.email, name="account_email"), |
| 25 |
path( |
| 26 |
"confirm-email/", |
| 27 |
views.email_verification_sent, |
| 28 |
name="account_email_verification_sent", |
| 29 |
), |
| 30 |
path( |
| 31 |
"password/change/", |
| 32 |
views.password_change, |
| 33 |
name="account_change_password", |
| 34 |
), |
| 35 |
path("password/set/", views.password_set, name="account_set_password"), |
| 36 |
# password reset |
| 37 |
path( |
| 38 |
"password/reset/", views.password_reset, name="account_reset_password" |
| 39 |
), |
| 40 |
path( |
| 41 |
"login/code/confirm/", |
| 42 |
views.confirm_login_code, |
| 43 |
name="account_confirm_login_code", |
| 44 |
), |
| 45 |
] |
| 46 |
) |
| 47 |
if not app_settings.EMAIL_VERIFICATION_BY_CODE_ENABLED: |
| 48 |
urlpatterns.append( |
| 49 |
re_path( |
| 50 |
r"^confirm-email/(?P<key>[-:\w]+)/$", |
| 51 |
views.confirm_email, |
| 52 |
name="account_confirm_email", |
| 53 |
) |
| 54 |
) |
| 55 |
if "phone" in app_settings.SIGNUP_FIELDS: |
| 56 |
urlpatterns.extend( |
| 57 |
[ |
| 58 |
path( |
| 59 |
"phone/verify/", |
| 60 |
views.verify_phone, |
| 61 |
name="account_verify_phone", |
| 62 |
), |
| 63 |
path( |
| 64 |
"phone/change/", |
| 65 |
views.change_phone, |
| 66 |
name="account_change_phone", |
| 67 |
), |
| 68 |
] |
| 69 |
) |
| 70 |
if app_settings.PASSWORD_RESET_BY_CODE_ENABLED: |
| 71 |
urlpatterns.extend( |
| 72 |
[ |
| 73 |
path( |
| 74 |
"password/reset/confirm/", |
| 75 |
views.confirm_password_reset_code, |
| 76 |
name="account_confirm_password_reset_code", |
| 77 |
), |
| 78 |
path( |
| 79 |
"password/reset/complete/", |
| 80 |
views.complete_password_reset, |
| 81 |
name="account_complete_password_reset", |
| 82 |
), |
| 83 |
path( |
| 84 |
"password/reset/done/", |
| 85 |
views.password_reset_from_key_done, |
| 86 |
name="account_password_reset_completed", |
| 87 |
), |
| 88 |
] |
| 89 |
) |
| 90 |
else: |
| 91 |
urlpatterns.extend( |
| 92 |
[ |
| 93 |
path( |
| 94 |
"password/reset/key/done/", |
| 95 |
views.password_reset_from_key_done, |
| 96 |
name="account_reset_password_from_key_done", |
| 97 |
), |
| 98 |
re_path( |
| 99 |
r"^password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$", |
| 100 |
views.password_reset_from_key, |
| 101 |
name="account_reset_password_from_key", |
| 102 |
), |
| 103 |
path( |
| 104 |
"password/reset/done/", |
| 105 |
views.password_reset_done, |
| 106 |
name="account_reset_password_done", |
| 107 |
), |
| 108 |
] |
| 109 |
) |
| 110 |
if getattr(settings, "MFA_PASSKEY_SIGNUP_ENABLED", False): |
| 111 |
urlpatterns.append( |
| 112 |
path( |
| 113 |
"signup/passkey/", |
| 114 |
views.signup_by_passkey, |
| 115 |
name="account_signup_by_passkey", |
| 116 |
) |
| 117 |
) |
| 118 |
|
| 119 |
if app_settings.LOGIN_BY_CODE_ENABLED: |
| 120 |
urlpatterns.extend( |
| 121 |
[ |
| 122 |
path( |
| 123 |
"login/code/", |
| 124 |
views.request_login_code, |
| 125 |
name="account_request_login_code", |
| 126 |
), |
| 127 |
] |
| 128 |
) |