diff --git a/apps/authentication/urls/view_urls.py b/apps/authentication/urls/view_urls.py
index 6972ae9cd..4bd785a08 100644
--- a/apps/authentication/urls/view_urls.py
+++ b/apps/authentication/urls/view_urls.py
@@ -33,6 +33,7 @@ urlpatterns = [
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'),
+ path('first-login/', users_view.UserFirstLoginView.as_view(), name='user-first-login'),
# openid
path('cas/', include(('authentication.backends.cas.urls', 'authentication'), namespace='cas')),
diff --git a/apps/templates/_message.html b/apps/templates/_message.html
index 19e559d36..39eacd17a 100644
--- a/apps/templates/_message.html
+++ b/apps/templates/_message.html
@@ -39,7 +39,7 @@
{% block first_login_message %}
{% if request.user.is_authenticated and request.user.is_first_login %}
- {% url 'users:user-first-login' as first_login_url %}
+ {% url 'authentication:user-first-login' as first_login_url %}
{% blocktrans %}
Your information was incomplete. Please click
this link to complete your information.
{% endblocktrans %}
diff --git a/apps/templates/_user_profile.html b/apps/templates/_user_profile.html
index dcab1c1a3..3e72f5b8e 100644
--- a/apps/templates/_user_profile.html
+++ b/apps/templates/_user_profile.html
@@ -23,7 +23,7 @@
{% for org in ADMIN_OR_AUDIT_ORGS %}
-
+
{{ org.name }}
{% if org.id == CURRENT_ORG.id %}
diff --git a/apps/users/templates/users/first_login.html b/apps/users/templates/users/first_login.html
index 417d20a3d..bffa2fc0e 100644
--- a/apps/users/templates/users/first_login.html
+++ b/apps/users/templates/users/first_login.html
@@ -1,145 +1,10 @@
-{% extends 'base.html' %}
+{% extends '_base_only_content.html' %}
{% load static %}
{% load i18n %}
{% load bootstrap3 %}
-
-{% block custom_head_css_js %}
-{{ wizard.form.media }}
-
-{% endblock %}
-{% block first_login_message %}{% endblock %}
+{% block title %} {% trans 'First Login' %} {% endblock %}
{% block content %}
-
-
-
-
-
-
{% trans 'First Login' %}
-
-
-
-
-
-
-
-{% endblock %}
-
-{% block custom_foot_js %}
-
+ 使用UI重构这个页面
{% endblock %}
diff --git a/apps/users/utils.py b/apps/users/utils.py
index 1932e3c0e..673215146 100644
--- a/apps/users/utils.py
+++ b/apps/users/utils.py
@@ -206,7 +206,7 @@ def get_user_or_pre_auth_user(request):
def redirect_user_first_login_or_index(request, redirect_field_name):
if request.user.is_first_login:
- return reverse('users:user-first-login')
+ return reverse('authentication:user-first-login')
url_in_post = request.POST.get(redirect_field_name)
if url_in_post:
return url_in_post
diff --git a/apps/users/views/profile/reset.py b/apps/users/views/profile/reset.py
index f1da16a4d..32b44f861 100644
--- a/apps/users/views/profile/reset.py
+++ b/apps/users/views/profile/reset.py
@@ -129,62 +129,6 @@ class UserResetPasswordView(FormView):
return redirect('authentication:reset-password-success')
-class UserFirstLoginView(PermissionsMixin, SessionWizardView):
+class UserFirstLoginView(PermissionsMixin, TemplateView):
template_name = 'users/first_login.html'
permission_classes = [IsValidUser]
- form_list = [
- forms.UserProfileForm,
- forms.UserPublicKeyForm,
- forms.UserMFAForm,
- forms.UserFirstLoginFinishForm
- ]
- file_storage = default_storage
-
- def dispatch(self, request, *args, **kwargs):
- if request.user.is_authenticated and not request.user.is_first_login:
- return redirect(reverse('index'))
- return super().dispatch(request, *args, **kwargs)
-
- def done(self, form_list, **kwargs):
- user = self.request.user
- for form in form_list:
- for field in form:
- if field.value():
- setattr(user, field.name, field.value())
- user.is_first_login = False
- user.save()
- context = {
- 'user_guide_url': settings.USER_GUIDE_URL
- }
- return render(self.request, 'users/first_login_done.html', context)
-
- def get_context_data(self, **kwargs):
- context = super().get_context_data(**kwargs)
- context.update({'app': _('Users'), 'action': _('First login')})
- return context
-
- def get_form_initial(self, step):
- user = self.request.user
- if step == '0':
- return {
- 'username': user.username or '',
- 'name': user.name or user.username,
- 'email': user.email or '',
- 'wechat': user.wechat or '',
- 'phone': user.phone or ''
- }
- return super().get_form_initial(step)
-
- def get_form(self, step=None, data=None, files=None):
- form = super().get_form(step, data, files)
- form.instance = self.request.user
-
- if isinstance(form, forms.UserMFAForm):
- choices = form.fields["mfa_level"].choices
- if self.request.user.mfa_force_enabled:
- choices = [(k, v) for k, v in choices if k == 2]
- else:
- choices = [(k, v) for k, v in choices if k in [0, 1]]
- form.fields["mfa_level"].choices = choices
- form.fields["mfa_level"].initial = self.request.user.mfa_level
- return form