mirror of https://github.com/jumpserver/jumpserver
Add ico, Modify forget_password
parent
dcff84958f
commit
9803dd9547
|
@ -9,18 +9,26 @@
|
||||||
|
|
||||||
.n-invalid {border: 1px solid #f00;}
|
.n-invalid {border: 1px solid #f00;}
|
||||||
|
|
||||||
.primary-panel {
|
|
||||||
border-color: #1ab394;
|
.primary-panel .ibox-title {
|
||||||
border-style: solid;
|
color: #ffffff;
|
||||||
border-width: 1px
|
background-color: #1AB394;
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-panel {
|
.primary-panel .ibox-content {
|
||||||
border-color: #23c6c8;
|
border: 1px solid #1AB394;
|
||||||
border-style: solid;
|
|
||||||
border-width: 1px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.info-panel .ibox-title {
|
||||||
|
color: #ffffff;
|
||||||
|
background-color: #23c6c8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-panel .ibox-content {
|
||||||
|
border: 1px solid #23c6c8;;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
th a {
|
th a {
|
||||||
color: #676a6c;
|
color: #676a6c;
|
||||||
}
|
}
|
||||||
|
@ -64,3 +72,7 @@ th a {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 100px 20px 20px 20px;
|
padding: 100px 20px 20px 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.no-borders-tr td {
|
||||||
|
border-top: none !important;
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.7 KiB |
|
@ -197,19 +197,20 @@ class User(AbstractUser):
|
||||||
return signing.dumps({'reset': self.id, 'email': self.email})
|
return signing.dumps({'reset': self.id, 'email': self.email})
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def reset_password(cls, token, new_password, max_age=3600):
|
def validate_reset_token(cls, token, max_age=3600):
|
||||||
try:
|
try:
|
||||||
data = signing.loads(token, max_age=max_age)
|
data = signing.loads(token, max_age=max_age)
|
||||||
user_id = data.get('reset', None)
|
user_id = data.get('reset', None)
|
||||||
user_email = data.get('email', '')
|
user_email = data.get('email', '')
|
||||||
user = cls.objects.get(id=user_id, email=user_email)
|
user = cls.objects.get(id=user_id, email=user_email)
|
||||||
user.set_password(new_password)
|
|
||||||
user.save()
|
|
||||||
return True
|
|
||||||
|
|
||||||
except signing.BadSignature, cls.DoesNotExist:
|
except signing.BadSignature, cls.DoesNotExist:
|
||||||
pass
|
user = None
|
||||||
return False
|
return user
|
||||||
|
|
||||||
|
def reset_password(self, new_password):
|
||||||
|
self.set_password(new_password)
|
||||||
|
self.save()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'user'
|
db_table = 'user'
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="gray-bg">
|
<body class="gray-bg">
|
||||||
<div class="passwordBox2 animated fadeInDown">
|
<div class="passwordBox animated fadeInDown">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
{% 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">
|
|
||||||
密码重置成功, 请返回登录页面登录系统 </a>.
|
|
||||||
</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>
|
|
||||||
|
|
||||||
</html>
|
|
|
@ -60,7 +60,7 @@
|
||||||
<div class="ibox-content">
|
<div class="ibox-content">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr class="no-borders-tr">
|
||||||
<td colspan="2">
|
<td colspan="2">
|
||||||
<img src="{{ user | user_avatar_url }}" class="img-circle" width="64" height="64">
|
<img src="{{ user | user_avatar_url }}" class="img-circle" width="64" height="64">
|
||||||
</td>
|
</td>
|
||||||
|
@ -119,16 +119,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-5" style="padding-left: 0px;">
|
<div class="col-sm-5" style="padding-left: 0px;">
|
||||||
<div class="ibox float-e-margins">
|
<div class="panel panel-primary">
|
||||||
<div class="ibox-title " style="background: #1ab394">
|
<div class="panel-heading">
|
||||||
<span style="color: white">快速修改</span>
|
<i class="fa fa-info-circle"></i> 快速修改
|
||||||
<div class="ibox-tools">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="ibox-content primary-panel">
|
<div class="panel-body">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr class="no-borders-tr">
|
||||||
<td width="50%">Active:</td>
|
<td width="50%">Active:</td>
|
||||||
<td><span style="float: right">
|
<td><span style="float: right">
|
||||||
<div class="switch">
|
<div class="switch">
|
||||||
|
@ -166,8 +164,8 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="no-borders">重置密钥:</td>
|
<td>重置密钥:</td>
|
||||||
<td class="no-borders">
|
<td>
|
||||||
<span style="float: right">
|
<span style="float: right">
|
||||||
<button type="button" class="btn btn-primary btn-xs" style="width: 54px;">重置</button>
|
<button type="button" class="btn btn-primary btn-xs" style="width: 54px;">重置</button>
|
||||||
</span>
|
</span>
|
||||||
|
@ -178,13 +176,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ibox float-e-margins">
|
<div class="panel panel-info">
|
||||||
<div class="ibox-title bg-primary" style="background: #1ab394">
|
<div class="panel-heading">
|
||||||
<span style="color: white">用户组</span>
|
<i class="fa fa-info-circle"></i> 用户组
|
||||||
<div class="ibox-tools">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="ibox-content primary-panel">
|
<div class="panel-body">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<form>
|
<form>
|
||||||
|
@ -199,7 +195,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" class="no-borders">
|
<td colspan="2" class="no-borders">
|
||||||
<button type="button" class="btn btn-primary btn-small">添加到用户组</button>
|
<button type="button" class="btn btn-info btn-small">添加到用户组</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -187,7 +187,6 @@ class UserForgetPasswordView(TemplateView):
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
email = request.POST.get('email')
|
email = request.POST.get('email')
|
||||||
print(email)
|
|
||||||
user = get_object_or_none(User, email=email)
|
user = get_object_or_none(User, email=email)
|
||||||
if not user:
|
if not user:
|
||||||
return self.get(request, errors='邮件地址错误,请重新输入')
|
return self.get(request, errors='邮件地址错误,请重新输入')
|
||||||
|
@ -225,6 +224,14 @@ class UserResetPasswordSuccessView(TemplateView):
|
||||||
class UserResetPasswordView(TemplateView):
|
class UserResetPasswordView(TemplateView):
|
||||||
template_name = 'users/reset_password.html'
|
template_name = 'users/reset_password.html'
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
token = request.GET.get('token')
|
||||||
|
user = User.validate_reset_token(token)
|
||||||
|
|
||||||
|
if not user:
|
||||||
|
kwargs.update({'errors': 'Token不正确或已过期'})
|
||||||
|
return super(UserResetPasswordView, self).get(request, *args, **kwargs)
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
password = request.POST.get('password')
|
password = request.POST.get('password')
|
||||||
password_confirm = request.POST.get('password-confirm')
|
password_confirm = request.POST.get('password-confirm')
|
||||||
|
@ -233,7 +240,9 @@ class UserResetPasswordView(TemplateView):
|
||||||
if password != password_confirm:
|
if password != password_confirm:
|
||||||
return self.get(request, errors='两次密码不匹配')
|
return self.get(request, errors='两次密码不匹配')
|
||||||
|
|
||||||
if not User.reset_password(token, password):
|
user = User.validate_reset_token(token)
|
||||||
|
if not user:
|
||||||
return self.get(request, errors='Token不正确或已过期')
|
return self.get(request, errors='Token不正确或已过期')
|
||||||
|
|
||||||
|
user.reset_password(password)
|
||||||
return HttpResponseRedirect(reverse('users:reset-password-success'))
|
return HttpResponseRedirect(reverse('users:reset-password-success'))
|
||||||
|
|
Loading…
Reference in New Issue