Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do permanent redirect from /user to /auth. #8748

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)))]