mirror of https://github.com/jumpserver/jumpserver
feat: 去掉第一次登录的那个导航
parent
8d58d58519
commit
68ccaf0cb3
|
@ -33,6 +33,7 @@ urlpatterns = [
|
||||||
name='user-otp-disable-authentication'),
|
name='user-otp-disable-authentication'),
|
||||||
path('profile/otp/update/', users_view.UserOtpUpdateView.as_view(), name='user-otp-update'),
|
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('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
|
# openid
|
||||||
path('cas/', include(('authentication.backends.cas.urls', 'authentication'), namespace='cas')),
|
path('cas/', include(('authentication.backends.cas.urls', 'authentication'), namespace='cas')),
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
{% block first_login_message %}
|
{% block first_login_message %}
|
||||||
{% if request.user.is_authenticated and request.user.is_first_login %}
|
{% if request.user.is_authenticated and request.user.is_first_login %}
|
||||||
<div class="alert alert-danger help-message alert-dismissable">
|
<div class="alert alert-danger help-message alert-dismissable">
|
||||||
{% url 'users:user-first-login' as first_login_url %}
|
{% url 'authentication:user-first-login' as first_login_url %}
|
||||||
{% blocktrans %}
|
{% blocktrans %}
|
||||||
Your information was incomplete. Please click <a href="{{ first_login_url }}"> this link </a>to complete your information.
|
Your information was incomplete. Please click <a href="{{ first_login_url }}"> this link </a>to complete your information.
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<input type="text" id="left-side-org-filter" placeholder="{% trans 'Search' %}" class="form-control">
|
<input type="text" id="left-side-org-filter" placeholder="{% trans 'Search' %}" class="form-control">
|
||||||
{% for org in ADMIN_OR_AUDIT_ORGS %}
|
{% for org in ADMIN_OR_AUDIT_ORGS %}
|
||||||
<li>
|
<li>
|
||||||
<a class="org-dropdown" href="{% url 'orgs:org-switch' pk=org.id %}" data-id="{{ org.id }}">
|
<a class="org-dropdown" href="" data-id="{{ org.id }}">
|
||||||
{{ org.name }}
|
{{ org.name }}
|
||||||
{% if org.id == CURRENT_ORG.id %}
|
{% if org.id == CURRENT_ORG.id %}
|
||||||
<span class="fa fa-circle" style="padding-top: 5px; color: #1ab394"></span>
|
<span class="fa fa-circle" style="padding-top: 5px; color: #1ab394"></span>
|
||||||
|
|
|
@ -1,145 +1,10 @@
|
||||||
{% extends 'base.html' %}
|
{% extends '_base_only_content.html' %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load bootstrap3 %}
|
{% load bootstrap3 %}
|
||||||
|
|
||||||
|
{% block title %} {% trans 'First Login' %} {% endblock %}
|
||||||
{% block custom_head_css_js %}
|
|
||||||
{{ wizard.form.media }}
|
|
||||||
<link href="{% static 'css/plugins/steps/jquery.steps.css' %}" rel="stylesheet">
|
|
||||||
{% endblock %}
|
|
||||||
{% block first_login_message %}{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="wrapper wrapper-content animated fadeInRight">
|
使用UI重构这个页面
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
<div class="ibox">
|
|
||||||
<div class="ibox-title">
|
|
||||||
<h5>{% trans 'First Login' %}</h5>
|
|
||||||
<div class="ibox-tools">
|
|
||||||
<a class="collapse-link">
|
|
||||||
<i class="fa fa-chevron-up"></i>
|
|
||||||
</a>
|
|
||||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
|
||||||
<i class="fa fa-wrench"></i>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="ibox-content">
|
|
||||||
<div class="wizard">
|
|
||||||
<div class="steps clearfix">
|
|
||||||
<ul role="tablist">
|
|
||||||
{% for step in wizard.steps.all %}
|
|
||||||
<li role="tab" class="{% ifequal step wizard.steps.first %}first{% endifequal %} {% ifequal step wizard.steps.current %}current{% else %}disabled{% endifequal %} {% ifequal step wizard.steps.last %}last{% endifequal %}"
|
|
||||||
aria-disabled="false" aria-selected="true">
|
|
||||||
<a class="fl_goto" name="wizard_goto_step" data-goto="{{ step }}">
|
|
||||||
<span class="number">
|
|
||||||
{% ifequal step '0' %}
|
|
||||||
1. {% trans "Profile" %}
|
|
||||||
{% endifequal %}
|
|
||||||
{% ifequal step '1' %}
|
|
||||||
2. {% trans "Public key" %}
|
|
||||||
{% endifequal %}
|
|
||||||
{% ifequal step '2' %}
|
|
||||||
3. {% trans "MFA" %}
|
|
||||||
{% endifequal %}
|
|
||||||
{% ifequal step '3' %}
|
|
||||||
4. {% trans "Finish" %}
|
|
||||||
{% endifequal %}
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{% endfor >%}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="content clearfix" style="background-color: #eee; border-radius:5px;">
|
|
||||||
<div class="row">
|
|
||||||
<form action="" method="post" class="form col-sm-8 p-m" id="fl_form" style="padding-left: 40px;">
|
|
||||||
{% csrf_token %}
|
|
||||||
{{ wizard.management_form }}
|
|
||||||
{% if form.finish_description %}
|
|
||||||
<b>{{ form.finish_description }}</b>
|
|
||||||
<br>
|
|
||||||
<input type="checkbox" id="acceptTerms">
|
|
||||||
<label for="acceptTerms" style="margin-top:20px">{% trans "I agree with the terms and conditions." %}</label>
|
|
||||||
<p id="noTerms" class="red-fonts" style="visibility: hidden; font-size: 10px; margin-top: 10px;">* {% trans 'Please choose the terms and conditions.' %}</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if wizard.steps.current == '1' and not request.user.can_update_ssh_key %}
|
|
||||||
<b id="ssh_key_help_text">{% trans 'User auth from {}, ssh key login is not supported' %}</b>
|
|
||||||
{% else %}
|
|
||||||
{% bootstrap_form wizard.form %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if form.mfa_description %}
|
|
||||||
<b>{{ form.mfa_description }}</b>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if form.pubkey_description and request.user.can_update_ssh_key %}
|
|
||||||
<a type="button" id="btn-reset-pubkey">{{ form.pubkey_description }}</a>
|
|
||||||
{% endif %}
|
|
||||||
</form>
|
|
||||||
<div class="col-sm-4">
|
|
||||||
<div class="text-center">
|
|
||||||
<div style="margin-top: 20px">
|
|
||||||
<i class="fa fa-sign-in" style="font-size: 180px;color: #e5e5e5 "></i>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="actions clearfix">
|
|
||||||
<ul>
|
|
||||||
{% if wizard.steps.prev %}
|
|
||||||
<li><a class="fl_goto" name="wizard_goto_step" data-goto="{{ wizard.steps.prev }}">{% trans "Previous" %}</a></li>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if wizard.steps.next %}
|
|
||||||
<li><a id="fl_submit" >{% trans "Next" %}</a></li>
|
|
||||||
{% else %}
|
|
||||||
<li><a id="fl_submit" style="width:66px;text-align: center;">{% trans "Finish" %}</a></li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block custom_foot_js %}
|
|
||||||
<script>
|
|
||||||
$(document).ready(function(){
|
|
||||||
var origin_ssh_key_text = $("#ssh_key_help_text").text();
|
|
||||||
var new_ssh_key_text = origin_ssh_key_text.replace('{}', "{{ request.user.source_display }}");
|
|
||||||
$("#ssh_key_help_text").html(new_ssh_key_text)
|
|
||||||
})
|
|
||||||
.on('click', ".fl_goto", function(){
|
|
||||||
var $form = $('#fl_form');
|
|
||||||
$('<input />', {'name': 'wizard_goto_step', 'value': $(this).data('goto'), 'type': 'hidden'}).appendTo($form);
|
|
||||||
$form.submit();
|
|
||||||
return false;
|
|
||||||
})
|
|
||||||
.on('click', '#fl_submit', function(){
|
|
||||||
var isFinish = $('#fl_submit').html() === "{% trans 'Finish' %}";
|
|
||||||
var noChecked = !$('#acceptTerms').prop('checked');
|
|
||||||
if ( isFinish && noChecked){
|
|
||||||
$('#noTerms').css('visibility', 'visible');
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$('#fl_form').submit();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.on('click', '#btn-reset-pubkey', function () {
|
|
||||||
var the_url = '{% url "users:user-pubkey-generate" %}';
|
|
||||||
window.open(the_url, "_blank");
|
|
||||||
$('#fl_form').submit();
|
|
||||||
})
|
|
||||||
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -206,7 +206,7 @@ def get_user_or_pre_auth_user(request):
|
||||||
|
|
||||||
def redirect_user_first_login_or_index(request, redirect_field_name):
|
def redirect_user_first_login_or_index(request, redirect_field_name):
|
||||||
if request.user.is_first_login:
|
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)
|
url_in_post = request.POST.get(redirect_field_name)
|
||||||
if url_in_post:
|
if url_in_post:
|
||||||
return url_in_post
|
return url_in_post
|
||||||
|
|
|
@ -129,62 +129,6 @@ class UserResetPasswordView(FormView):
|
||||||
return redirect('authentication:reset-password-success')
|
return redirect('authentication:reset-password-success')
|
||||||
|
|
||||||
|
|
||||||
class UserFirstLoginView(PermissionsMixin, SessionWizardView):
|
class UserFirstLoginView(PermissionsMixin, TemplateView):
|
||||||
template_name = 'users/first_login.html'
|
template_name = 'users/first_login.html'
|
||||||
permission_classes = [IsValidUser]
|
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
|
|
||||||
|
|
Loading…
Reference in New Issue