Skip to content

Commit

Permalink
Change path to re_path and add ?$ to make trailing slash optional
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebarbaruiva committed Nov 22, 2024
1 parent 54f9aa4 commit dd28e33
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 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('verify-email/?$', VerifyEmailView.as_view(), name='rest_verify_email'),
re_path('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 @@ -21,11 +21,11 @@
# view from:
# django-allauth https://github.com/pennersr/django-allauth/blob/master/allauth/account/views.py
re_path(
r'^account-confirm-email/(?P<key>[-:\w]+)/$', TemplateView.as_view(),
r'^account-confirm-email/?$(?P<key>[-:\w]+)/$', TemplateView.as_view(),
name='account_confirm_email',
),
path(
'account-email-verification-sent/', TemplateView.as_view(),
re_path(
'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('password/reset/?$', PasswordResetView.as_view(), name='rest_password_reset'),
re_path('password/reset/confirm/?$', PasswordResetConfirmView.as_view(), name='rest_password_reset_confirm'),
re_path('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('logout/?$', LogoutView.as_view(), name='rest_logout'),
re_path('user/?$', UserDetailsView.as_view(), name='rest_user_details'),
re_path('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('token/verify/?$', TokenVerifyView.as_view(), name='token_verify'),
re_path('token/refresh/?$', get_refresh_view().as_view(), name='token_refresh'),
]

0 comments on commit dd28e33

Please sign in to comment.