mirror of https://github.com/jumpserver/jumpserver
Update login error message
parent
b8bebc9b64
commit
10d51ada37
|
@ -33,7 +33,7 @@
|
|||
|
||||
{% if messages %}
|
||||
<p>
|
||||
<div class="alert alert-success">
|
||||
<div class="alert alert-success" id="messages">
|
||||
{{ messages }}
|
||||
</div>
|
||||
</p>
|
||||
|
@ -52,9 +52,26 @@
|
|||
Copyright Jumpserver.org
|
||||
</div>
|
||||
<div class="col-md-6 text-right">
|
||||
<small>© 2014-2016</small>
|
||||
<small>2014-2016</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
var time=5;
|
||||
function redirect_page() {
|
||||
if (time >= 0) {
|
||||
var messages = '{{ messages }}, <b>' + time +'</b> ...';
|
||||
$('#messages').html(messages);
|
||||
time--;
|
||||
setTimeout(redirect_page, 1000);
|
||||
}
|
||||
else {
|
||||
window.location.href = "{{ redirect_url }}";
|
||||
}
|
||||
}
|
||||
{% if auto_redirect %}
|
||||
window.onload = redirect_page
|
||||
{% endif %}
|
||||
</script>
|
||||
</html>
|
||||
|
|
|
@ -1 +1 @@
|
|||
[{"model": "users.role", "pk": 1, "fields": {"name": "Administrator", "date_added": "2016-08-20T17:03:42.631Z", "created_by": "System", "comment": "\u7ba1\u7406\u5458", "permissions": [16, 17, 18, 19, 20, 21, 10, 11, 12, 13, 14, 15, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 1, 2, 3, 4, 5, 6, 7, 8, 9]}}, {"model": "users.role", "pk": 2, "fields": {"name": "User", "date_added": "2016-08-20T17:03:42.671Z", "created_by": "System", "comment": "\u7528\u6237", "permissions": []}}, {"model": "users.role", "pk": 3, "fields": {"name": "Auditor", "date_added": "2016-08-20T17:03:42.683Z", "created_by": "System", "comment": "\u5ba1\u8ba1\u5458", "permissions": []}}, {"model": "users.usergroup", "pk": 1, "fields": {"name": "ALL", "comment": "Default usergroup for all user", "date_added": "2016-08-20T17:03:42.693Z", "created_by": "System"}}, {"model": "users.user", "pk": 1, "fields": {"password": "pbkdf2_sha256$30000$xZUhPadgI8rs$n2rm5futcOv7Ww4b4BflN8K90Vk3u7ozfnOS7GQq0ns=", "last_login": null, "is_superuser": false, "first_name": "", "last_name": "", "is_staff": false, "is_active": true, "date_joined": "2016-08-20T17:03:42.752Z", "username": "admin", "name": "Administrator", "email": "admin@jumpserver.org", "avatar": "", "wechat": "", "phone": "", "enable_otp": false, "secret_key_otp": "", "role": 1, "private_key": "", "public_key": "", "comment": "Administrator is the super user of system", "date_expired": "2086-08-03T17:03:42.753Z", "created_by": "System", "user_permissions": [], "groups": [1]}}][{"model": "users.usergroup", "pk": 1, "fields": {"name": "Default", "comment": "Default user group for all user", "date_added": "2016-08-24T08:24:34.436Z", "created_by": "System"}}, {"model": "users.user", "pk": 1, "fields": {"password": "pbkdf2_sha256$30000$MC3vobX7pa0C$l9qIj4UwHqODnj1hMvVy9DjLxbBumZaioQWIFrWQR7c=", "last_login": null, "first_name": "", "last_name": "", "is_active": true, "date_joined": "2016-08-24T08:24:34.438Z", "username": "admin", "name": "Administrator", "email": "admin@jumpserver.org", "role": "Admin", "avatar": "", "wechat": "", "phone": "", "enable_otp": false, "secret_key_otp": "", "private_key": "", "public_key": "", "comment": "Administrator is the super user of system", "date_expired": "2086-08-07T08:24:34.438Z", "created_by": "System", "user_permissions": [], "groups": [1]}}]
|
||||
[{"model": "users.usergroup", "pk": 1, "fields": {"name": "Default", "comment": "Default user group for all user", "date_added": "2016-09-02T14:32:32Z", "created_by": "System"}}, {"model": "users.user", "pk": 1, "fields": {"password": "pbkdf2_sha256$30000$QU8p6Y6ep8VP$Zhrgn0Issfc8ozrNSdSGmyb3X7lRAbc3EEWdc2RTj/M=", "last_login": null, "first_name": "", "last_name": "", "is_active": true, "date_joined": "2016-09-02T14:32:32Z", "username": "admin", "name": "Administrator", "email": "admin@jumpserver.org", "role": "Admin", "avatar": "", "wechat": "", "phone": "", "enable_otp": false, "secret_key_otp": "", "private_key": "", "public_key": "", "comment": "Administrator is the super user of system", "is_first_login": false, "date_expired": "2086-08-16T14:32:32Z", "created_by": "System", "user_permissions": [], "groups": [1]}}]
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,64 @@
|
|||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>{{ title }}</title>
|
||||
|
||||
{% include '_head_css_js.html' %}
|
||||
<link href="{% static "css/jumpserver.css" %}" rel="stylesheet">
|
||||
<script src="{% static "js/jumpserver.js" %}"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="gray-bg">
|
||||
<div class="passwordBox2 animated fadeInDown">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="ibox-content">
|
||||
<div>
|
||||
<img src="{% static 'img/logo.png' %}" style="margin: auto" width="82" height="82">
|
||||
<h2 style="display: inline">Jumpserver</h2>
|
||||
</div>
|
||||
<p>
|
||||
<div class="alert alert-success" id="messages">
|
||||
退出登录成功
|
||||
</div>
|
||||
</p>
|
||||
<div class="row">
|
||||
<div class="col-lg-3">
|
||||
<a href="{% url "users:login" %}" class="btn btn-primary block full-width m-b">返回</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
Copyright Jumpserver.org
|
||||
</div>
|
||||
<div class="col-md-6 text-right">
|
||||
<small>2014-2016</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
var time=2;
|
||||
function redirect_page() {
|
||||
if (time >= 0) {
|
||||
var messages = '退出登录成功,<b>' + time +'</b> 秒后 返回到登录页面 ';
|
||||
$('#messages').html(messages);
|
||||
time--;
|
||||
setTimeout(redirect_page, 1000);
|
||||
}
|
||||
else {
|
||||
window.location.href = "{% url 'users:login' %}";
|
||||
}
|
||||
}
|
||||
window.onload = redirect_page
|
||||
</script>
|
||||
</html>
|
|
@ -110,8 +110,8 @@
|
|||
<td><b>{{ user.last_login|date:"Y-m-j H:i:s" }}</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="no-borders">描述:</td>
|
||||
<td class="no-borders"><b>{{ user.comment }}</b></td>
|
||||
<td>描述:</td>
|
||||
<td><b>{{ user.comment }}</b></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.conf.urls import url, include
|
||||
from django.contrib.auth import views as auth_views
|
||||
from django.urls import reverse_lazy
|
||||
|
||||
import views
|
||||
import api
|
||||
|
@ -8,7 +9,7 @@ app_name = 'users'
|
|||
|
||||
urlpatterns = [
|
||||
url(r'^login$', views.UserLoginView.as_view(), name='login'),
|
||||
url(r'^logout$', auth_views.logout, {'template_name': 'users/login.html'}, name='logout'),
|
||||
url(r'^logout$', views.UserLogoutView.as_view(), name='logout'),
|
||||
url(r'^captcha/', include('captcha.urls')),
|
||||
url(r'^password/forget$', views.UserForgetPasswordView.as_view(), name='forget-password'),
|
||||
url(r'^password/forget/sendmail-success$',
|
||||
|
|
|
@ -15,7 +15,7 @@ from django.views.generic.detail import DetailView
|
|||
from django.contrib.messages.views import SuccessMessageMixin
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.contrib.auth import views as auth_view, authenticate, login
|
||||
from django.contrib.auth import views as auth_view, authenticate, login, logout
|
||||
|
||||
from common.utils import get_object_or_none
|
||||
|
||||
|
@ -34,8 +34,11 @@ class UserLoginView(FormView):
|
|||
|
||||
def get(self, request, *args, **kwargs):
|
||||
if self.request.user.is_staff:
|
||||
return redirect(request.GET.get(self.redirect_field_name, reverse('index')))
|
||||
return super(UserLoginView, self).get(request, *args, **kwargs)
|
||||
return redirect(request.POST.get(self.redirect_field_name, reverse('index')))
|
||||
# Todo: Django have bug, lose context issue: https://github.com/django/django/pull/7202
|
||||
# so we jump it and use origin method render_to_response
|
||||
# return super(UserLoginView, self).get(request, *args, **kwargs)
|
||||
return self.render_to_response(self.get_context_data(**kwargs))
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
form = self.get_form()
|
||||
|
@ -51,6 +54,25 @@ class UserLoginView(FormView):
|
|||
return redirect(request.GET.get(self.redirect_field_name, reverse('index')))
|
||||
|
||||
|
||||
class UserLogoutView(TemplateView):
|
||||
template_name = 'common/flash_message_standalone.html'
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
logout(request)
|
||||
|
||||
return super(UserLogoutView, self).get(request)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = {
|
||||
'title': '退出登录成功',
|
||||
'messages': '退出登录成功, 返回登录页面',
|
||||
'redirect_url': reverse('users:login'),
|
||||
'auto_redirect': True,
|
||||
}
|
||||
kwargs.update(context)
|
||||
return super(UserLogoutView, self).get_context_data(**kwargs)
|
||||
|
||||
|
||||
class UserListView(AdminUserRequiredMixin, ListView):
|
||||
model = User
|
||||
paginate_by = settings.CONFIG.DISPLAY_PER_PAGE
|
||||
|
@ -239,8 +261,9 @@ class UserResetPasswordSuccessView(TemplateView):
|
|||
def get_context_data(self, **kwargs):
|
||||
context = {
|
||||
'title': '重设密码成功',
|
||||
'messages': '密码重置成功, 请返回登录页面登录系统',
|
||||
'messages': '密码重置成功, 返回登录页面 ',
|
||||
'redirect_url': reverse('users:login'),
|
||||
'auto_redirect': True,
|
||||
}
|
||||
kwargs.update(context)
|
||||
return super(UserResetPasswordSuccessView, self).get_context_data(**kwargs)
|
||||
|
@ -263,7 +286,7 @@ class UserResetPasswordView(TemplateView):
|
|||
token = request.GET.get('token')
|
||||
|
||||
if password != password_confirm:
|
||||
return self.get(request, errors='两次密码不匹配')
|
||||
return self.get(request, errors='两次密码不一致')
|
||||
|
||||
user = User.validate_reset_token(token)
|
||||
if not user:
|
||||
|
|
|
@ -52,7 +52,7 @@ class Config:
|
|||
# When Django start it will bind this host and port
|
||||
# ./manage.py runserver 127.0.0.1:8080
|
||||
# Todo: Gunicorn or uwsgi run may be use it
|
||||
HTTP_LISTEN_HOST = '127.0.0.1'
|
||||
HTTP_LISTEN_HOST = '0.0.0.0'
|
||||
HTTP_LISTEN_PORT = 8080
|
||||
|
||||
# Use Redis as broker for celery and web socket
|
||||
|
|
|
@ -19,8 +19,8 @@ apps_dir = os.path.join(BASE_DIR, 'apps')
|
|||
|
||||
|
||||
def start_django():
|
||||
http_host = CONFIG.HTTP_BIND_HOST or 'locahost'
|
||||
http_port = CONFIG.HTTP_LISTEN_HOST or '8080'
|
||||
http_host = CONFIG.HTTP_LISTEN_HOST or 'locahost'
|
||||
http_port = CONFIG.HTTP_LISTEN_PORT or '8080'
|
||||
os.chdir(apps_dir)
|
||||
print('start django')
|
||||
subprocess.call('python ./manage.py runserver %s:%s' % (http_host, http_port), shell=True)
|
||||
|
|
Loading…
Reference in New Issue