Skip to content

Commit

Permalink
Merge pull request #8748 from rtibbles/user_auth_redirect
Browse files Browse the repository at this point in the history
Do permanent redirect from /user to /auth.
  • Loading branch information
indirectlylit committed Nov 19, 2021
2 parents 9770c51 + 91b65ac commit 387eaed
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kolibri/core/test/test_key_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class AllUrlsTest(APITransactionTestCase):

# Allow codes that may indicate a poorly formed response
# 412 is returned from endpoints that have required GET params when these are not supplied
allowed_http_codes = [200, 302, 400, 401, 403, 404, 405, 412]
allowed_http_codes = [200, 301, 302, 400, 401, 403, 404, 405, 412]

def setUp(self):
provision_device()
Expand Down
1 change: 1 addition & 0 deletions kolibri/plugins/user_auth/kolibri_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

class UserAuth(KolibriPluginBase):
translated_view_urls = "urls"
root_view_urls = "root_urls"

@property
def url_slug(self):
Expand Down
20 changes: 20 additions & 0 deletions kolibri/plugins/user_auth/root_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
This is here to enable redirects from the old /user endpoint to /auth
"""
from django.conf.urls import include
from django.conf.urls import url
from django.views.generic.base import RedirectView

from kolibri.core.device.translation import i18n_patterns

redirect_patterns = [
url(
r"^user/$",
RedirectView.as_view(
pattern_name="kolibri:kolibri.plugins.user_auth:user_auth", permanent=True
),
name="redirect_user",
),
]

urlpatterns = [url(r"", include(i18n_patterns(redirect_patterns)))]

0 comments on commit 387eaed

Please sign in to comment.