From 629bf80e62ccd5e36622aa644b369961c0d64317 Mon Sep 17 00:00:00 2001 From: hachiyanagi-ks Date: Thu, 1 Dec 2016 17:27:38 +0900 Subject: [PATCH] Add custom csrf view #1511 (#1513) --- ga/conf/locale/ja_JP/LC_MESSAGES/gacco.po | 16 +++++++++ lms/envs/common.py | 3 ++ lms/templates/ga_csrf_failure.html | 36 +++++++++++++++++++++ openedx/core/djangoapps/ga_csrf/__init__.py | 0 openedx/core/djangoapps/ga_csrf/views.py | 10 ++++++ 5 files changed, 65 insertions(+) create mode 100644 lms/templates/ga_csrf_failure.html create mode 100644 openedx/core/djangoapps/ga_csrf/__init__.py create mode 100644 openedx/core/djangoapps/ga_csrf/views.py diff --git a/ga/conf/locale/ja_JP/LC_MESSAGES/gacco.po b/ga/conf/locale/ja_JP/LC_MESSAGES/gacco.po index ffdb4e284ac0..73ede5132375 100644 --- a/ga/conf/locale/ja_JP/LC_MESSAGES/gacco.po +++ b/ga/conf/locale/ja_JP/LC_MESSAGES/gacco.po @@ -1235,3 +1235,19 @@ msgstr "講座名は{max_length}文字以内で設定してください。" #: cms/djangoapps/models/settings/course_metadata.py msgid "Course display name, please be up to {max_length} characters." msgstr "講座の表示名は{max_length}文字以内で設定してください。" + +#: lms/templates/ga_csrf_failure.html +msgid "The sign in errors are caused by communication line or your browser settings. Please try following method." +msgstr "通信回線、またはブラウザの設定が原因と思われます。以下の解決方法をお試しください。" + +#: lms/templates/ga_csrf_failure.html +msgid "Close your browser screen once and sign in again after a while. Also confirm a connection state of your communication line." +msgstr "画面を一旦閉じ、少し時間を置いてから再度ログインしてください。 また、インターネット回線の接続状態を確認してください。" + +#: lms/templates/ga_csrf_failure.html +msgid "Enabling cookie support on your browser." +msgstr "お使いのブラウザソフトのcookie(クッキー)設定を有効にしてください。" + +#: lms/templates/ga_csrf_failure.html +msgid "If not resolve your sign in problem, please try other browser." +msgstr "それでも解決しない場合は、他のブラウザでお試しください。" diff --git a/lms/envs/common.py b/lms/envs/common.py index 7a002526efa8..4dfa2d0cd07e 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -2763,5 +2763,8 @@ ##### Format ##### FORMAT_MODULE_PATH = ['conf.formats'] +##### CSRF ##### +CSRF_FAILURE_VIEW = 'openedx.core.djangoapps.ga_csrf.views.csrf_failure' + ##### Settings for Biz ##### from biz.envs.common import * diff --git a/lms/templates/ga_csrf_failure.html b/lms/templates/ga_csrf_failure.html new file mode 100644 index 000000000000..8b72c4f47419 --- /dev/null +++ b/lms/templates/ga_csrf_failure.html @@ -0,0 +1,36 @@ +<%! +from django.utils.translation import ugettext as _ +%> + + + + + 403 Forbidden + + + +
+

${_("The sign in errors are caused by communication line or your browser settings. Please try following method.")}

+
    +
  1. ${_("Close your browser screen once and sign in again after a while. Also confirm a connection state of your communication line.")}
  2. +
  3. ${_("Enabling cookie support on your browser.")}
  4. +
+

${_("If not resolve your sign in problem, please try other browser.")}

+
+ + diff --git a/openedx/core/djangoapps/ga_csrf/__init__.py b/openedx/core/djangoapps/ga_csrf/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/openedx/core/djangoapps/ga_csrf/views.py b/openedx/core/djangoapps/ga_csrf/views.py new file mode 100644 index 000000000000..248012f0e918 --- /dev/null +++ b/openedx/core/djangoapps/ga_csrf/views.py @@ -0,0 +1,10 @@ +""" +Views for ga_csrf +""" +from django.http import HttpResponseForbidden + +from edxmako.shortcuts import render_to_response + + +def csrf_failure(request, reason=''): # pylint: disable=unused-argument + return HttpResponseForbidden(render_to_response('ga_csrf_failure.html'))