Skip to content

Commit

Permalink
Change path to re_path and add ?$ to make trailing slash optional (#667)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebarbaruiva authored Nov 30, 2024
1 parent 990b2dd commit 1a33e99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions dj_rest_auth/registration/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

urlpatterns = [
path('', RegisterView.as_view(), name='rest_register'),
path('verify-email/', VerifyEmailView.as_view(), name='rest_verify_email'),
path('resend-email/', ResendEmailVerificationView.as_view(), name="rest_resend_email"),
re_path(r'verify-email/?$', VerifyEmailView.as_view(), name='rest_verify_email'),
re_path(r'resend-email/?$', ResendEmailVerificationView.as_view(), name="rest_resend_email"),

# This url is used by django-allauth and empty TemplateView is
# defined just to allow reverse() call inside app, for example when email
Expand All @@ -24,8 +24,8 @@
r'^account-confirm-email/(?P<key>[-:\w]+)/$', TemplateView.as_view(),
name='account_confirm_email',
),
path(
'account-email-verification-sent/', TemplateView.as_view(),
re_path(
r'account-email-verification-sent/?$', TemplateView.as_view(),
name='account_email_verification_sent',
),
]
18 changes: 9 additions & 9 deletions dj_rest_auth/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.urls import path
from django.urls import re_path

from dj_rest_auth.app_settings import api_settings

Expand All @@ -10,13 +10,13 @@

urlpatterns = [
# URLs that do not require a session or valid token
path('password/reset/', PasswordResetView.as_view(), name='rest_password_reset'),
path('password/reset/confirm/', PasswordResetConfirmView.as_view(), name='rest_password_reset_confirm'),
path('login/', LoginView.as_view(), name='rest_login'),
re_path(r'password/reset/?$', PasswordResetView.as_view(), name='rest_password_reset'),
re_path(r'password/reset/confirm/?$', PasswordResetConfirmView.as_view(), name='rest_password_reset_confirm'),
re_path(r'login/?$', LoginView.as_view(), name='rest_login'),
# URLs that require a user to be logged in with a valid session / token.
path('logout/', LogoutView.as_view(), name='rest_logout'),
path('user/', UserDetailsView.as_view(), name='rest_user_details'),
path('password/change/', PasswordChangeView.as_view(), name='rest_password_change'),
re_path(r'logout/?$', LogoutView.as_view(), name='rest_logout'),
re_path(r'user/?$', UserDetailsView.as_view(), name='rest_user_details'),
re_path(r'password/change/?$', PasswordChangeView.as_view(), name='rest_password_change'),
]

if api_settings.USE_JWT:
Expand All @@ -25,6 +25,6 @@
from dj_rest_auth.jwt_auth import get_refresh_view

urlpatterns += [
path('token/verify/', TokenVerifyView.as_view(), name='token_verify'),
path('token/refresh/', get_refresh_view().as_view(), name='token_refresh'),
re_path(r'token/verify/?$', TokenVerifyView.as_view(), name='token_verify'),
re_path(r'token/refresh/?$', get_refresh_view().as_view(), name='token_refresh'),
]

0 comments on commit 1a33e99

Please sign in to comment.