From 96551856a248316955c61e122c603296b958d825 Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 3 Jun 2020 11:06:44 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E9=83=A8=E5=88=86view=E6=94=BE?= =?UTF-8?q?=E5=88=B0auth=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/authentication/login.html | 2 +- .../templates/authentication/xpack_login.html | 2 +- apps/authentication/urls/view_urls.py | 19 +++++++++++++++++++ apps/jumpserver/urls.py | 3 ++- apps/jumpserver/views/other.py | 8 +++++++- apps/users/models/user.py | 2 +- .../users/user_otp_enable_install_app.html | 2 +- apps/users/templates/users/user_profile.html | 6 +++--- apps/users/utils.py | 10 +++++----- apps/users/views/login.py | 4 ++-- apps/users/views/profile/otp.py | 10 +++++----- 11 files changed, 47 insertions(+), 21 deletions(-) diff --git a/apps/authentication/templates/authentication/login.html b/apps/authentication/templates/authentication/login.html index 9cacdf4ff..8812f582b 100644 --- a/apps/authentication/templates/authentication/login.html +++ b/apps/authentication/templates/authentication/login.html @@ -46,7 +46,7 @@
- + {% trans 'Forgot password' %}?
diff --git a/apps/authentication/templates/authentication/xpack_login.html b/apps/authentication/templates/authentication/xpack_login.html index ba3f92308..8c1cb24f8 100644 --- a/apps/authentication/templates/authentication/xpack_login.html +++ b/apps/authentication/templates/authentication/xpack_login.html @@ -112,7 +112,7 @@
- + {% trans 'Forgot password' %}?
diff --git a/apps/authentication/urls/view_urls.py b/apps/authentication/urls/view_urls.py index 62283f1f5..6972ae9cd 100644 --- a/apps/authentication/urls/view_urls.py +++ b/apps/authentication/urls/view_urls.py @@ -4,6 +4,7 @@ from django.urls import path, include from .. import views +from users import views as users_view app_name = 'authentication' @@ -15,6 +16,24 @@ urlpatterns = [ path('login/guard/', views.UserLoginGuardView.as_view(), name='login-guard'), path('logout/', views.UserLogoutView.as_view(), name='logout'), + # 原来在users中的 + path('password/forgot/', users_view.UserForgotPasswordView.as_view(), name='forgot-password'), + path('password/forgot/sendmail-success/', users_view.UserForgotPasswordSendmailSuccessView.as_view(), + name='forgot-password-sendmail-success'), + path('password/reset/', users_view.UserResetPasswordView.as_view(), name='reset-password'), + path('password/reset/success/', users_view.UserResetPasswordSuccessView.as_view(), name='reset-password-success'), + path('password/verify/', users_view.UserVerifyPasswordView.as_view(), name='user-verify-password'), + + # Profile + path('profile/otp/enable/start/', users_view.UserOtpEnableStartView.as_view(), name='user-otp-enable-start'), + path('profile/otp/enable/install-app/', users_view.UserOtpEnableInstallAppView.as_view(), + name='user-otp-enable-install-app'), + path('profile/otp/enable/bind/', users_view.UserOtpEnableBindView.as_view(), name='user-otp-enable-bind'), + path('profile/otp/disable/authentication/', users_view.UserDisableMFAView.as_view(), + name='user-otp-disable-authentication'), + path('profile/otp/update/', users_view.UserOtpUpdateView.as_view(), name='user-otp-update'), + path('profile/otp/settings-success/', users_view.UserOtpSettingsSuccessView.as_view(), name='user-otp-settings-success'), + # openid path('cas/', include(('authentication.backends.cas.urls', 'authentication'), namespace='cas')), path('openid/', include(('jms_oidc_rp.urls', 'authentication'), namespace='openid')), diff --git a/apps/jumpserver/urls.py b/apps/jumpserver/urls.py index bb1782a26..14379b924 100644 --- a/apps/jumpserver/urls.py +++ b/apps/jumpserver/urls.py @@ -67,7 +67,7 @@ if settings.XPACK_ENABLED: ) js_i18n_patterns = i18n_patterns( - path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'), + # path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'), ) @@ -87,6 +87,7 @@ urlpatterns = [ # External apps url path('core/auth/captcha/', include('captcha.urls')), path('core/', include(app_view_patterns)), + path('ui/', views.UIView.as_view()) ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ diff --git a/apps/jumpserver/views/other.py b/apps/jumpserver/views/other.py index 17a7dfd6c..ca58f70ac 100644 --- a/apps/jumpserver/views/other.py +++ b/apps/jumpserver/views/other.py @@ -16,7 +16,7 @@ from common.http import HttpResponseTemporaryRedirect __all__ = [ 'LunaView', 'I18NView', 'KokoView', 'WsView', 'HealthCheckView', - 'redirect_format_api', 'redirect_old_apps_view' + 'redirect_format_api', 'redirect_old_apps_view', 'UIView' ] @@ -75,6 +75,12 @@ class WsView(APIView): return JsonResponse({"msg": msg}) +class UIView(View): + def get(self, request): + msg = "如果你能看到这个页面,证明你的配置是有问题的,请参考文档设置好nginx, UI由Lina项目提供" + return HttpResponse(msg) + + class KokoView(View): def get(self, request): msg = _( diff --git a/apps/users/models/user.py b/apps/users/models/user.py index 3e38cbb18..473f62197 100644 --- a/apps/users/models/user.py +++ b/apps/users/models/user.py @@ -437,7 +437,7 @@ class MFAMixin: if not self.mfa_enabled: return False, None if self.mfa_is_otp() and not self.otp_secret_key: - return True, reverse('users:user-otp-enable-start') + return True, reverse('authentication:user-otp-enable-start') return False, None diff --git a/apps/users/templates/users/user_otp_enable_install_app.html b/apps/users/templates/users/user_otp_enable_install_app.html index e3462cd3a..37b3e612b 100644 --- a/apps/users/templates/users/user_otp_enable_install_app.html +++ b/apps/users/templates/users/user_otp_enable_install_app.html @@ -26,7 +26,7 @@

{% trans 'After installation, click the next step to enter the binding page (if installed, go to the next step directly).' %}

- +