Commit c1fb72f3 authored by guanghongwei's avatar guanghongwei

޸ĵ½˳

parent 35d9be5c
...@@ -8,6 +8,8 @@ urlpatterns = patterns('', ...@@ -8,6 +8,8 @@ urlpatterns = patterns('',
(r'^$', 'jumpserver.views.base'), (r'^$', 'jumpserver.views.base'),
(r'^skin_config/$', 'jumpserver.views.skin_config'), (r'^skin_config/$', 'jumpserver.views.skin_config'),
(r'^base/$', 'jumpserver.views.base'), (r'^base/$', 'jumpserver.views.base'),
(r'^login/$', 'jumpserver.views.login'),
(r'^logout/$', 'jumpserver.views.logout'),
(r'^juser/', include('juser.urls')), (r'^juser/', include('juser.urls')),
(r'^jperm/', include('jperm.urls')), (r'^jperm/', include('jperm.urls')),
url(r'^jasset/', include('jasset.urls')), url(r'^jasset/', include('jasset.urls')),
......
#coding: utf-8 #coding: utf-8
import hashlib
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import render_to_response from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from juser.models import User
def md5_crypt(string):
return hashlib.new("md5", string).hexdigest()
def base(request): def base(request):
...@@ -12,3 +21,36 @@ def skin_config(request): ...@@ -12,3 +21,36 @@ def skin_config(request):
return render_to_response('skin_config.html') return render_to_response('skin_config.html')
def login(request):
"""登录界面"""
if request.session.get('username'):
return HttpResponseRedirect('/')
if request.method == 'GET':
return render_to_response('login.html')
else:
username = request.POST.get('username')
password = request.POST.get('password')
user = User.objects.filter(username=username)
if user:
user = user[0]
if md5_crypt(password) == user.password:
request.session['username'] = username
if user.role == 'SU':
request.session['role'] = 2
elif user.role == 'GA':
request.session['role'] = 1
else:
request.session['role'] = 0
return HttpResponseRedirect('/')
else:
error = '密码错误,请重新输入。'
else:
error = '用户不存在。'
return render_to_response('login.html', {'error': error})
def logout(request):
request.session.delete()
return HttpResponseRedirect('/login/')
...@@ -33,10 +33,6 @@ if LDAP_ENABLE: ...@@ -33,10 +33,6 @@ if LDAP_ENABLE:
LDAP_ROOT_PW = CONF.get('ldap', 'root_pw') LDAP_ROOT_PW = CONF.get('ldap', 'root_pw')
def md5_crypt(string):
return hashlib.new("md5", string).hexdigest()
def gen_rand_pwd(num): def gen_rand_pwd(num):
"""生成随机密码""" """生成随机密码"""
seed = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" seed = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<link rel="shortcut icon" href="/static/img/facio.ico" type="image/x-icon"> <link rel="shortcut icon" href="/static/img/facio.ico" type="image/x-icon">
{% include 'link_css.html' %} {% include 'link_css.html' %}
{% include 'script.html' %}
</head> </head>
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</div> </div>
</div> </div>
<!--{% include 'script.html' %}--> {# <!--{% include 'script.html' %}-->#}
</body> </body>
{% include 'script.html' %}
</html> </html>
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
</div> </div>
<div class="hr-line-dashed"></div> <div class="hr-line-dashed"></div>
<div class="form-group"> <div class="form-group">
<label for="email" class="col-sm-2 control-label">Email</label> <label for="email" class="col-sm-2 control-label">Email<span class="red-fonts">*</span></label>
<div class="col-sm-8"> <div class="col-sm-8">
<input id="email" name="email" type="email" placeholder="Email" class="form-control" value="{{ email }}"> <input id="email" name="email" type="email" placeholder="Email" class="form-control" value="{{ email }}">
</div> </div>
...@@ -191,6 +191,12 @@ $('#userForm').validator({ ...@@ -191,6 +191,12 @@ $('#userForm').validator({
ok: "", ok: "",
msg: {required: "必须填写"} msg: {required: "必须填写"}
}, },
"email": {
rule: "required",
tip: "Email",
ok: "",
msg: {required: "必须填写"}
},
"role": { "role": {
rule: "checked", rule: "checked",
tip: "角色", tip: "角色",
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JumpServer | Login</title> <title>JumpServer | Login</title>
<link rel="shortcut icon" href="/static/img/facio.ico" type="image/x-icon">
<link href="/static/css/bootstrap.min.css" rel="stylesheet"> <link href="/static/css/bootstrap.min.css" rel="stylesheet">
<link href="/static/font-awesome/css/font-awesome.css" rel="stylesheet"> <link href="/static/font-awesome/css/font-awesome.css" rel="stylesheet">
...@@ -22,22 +22,25 @@ ...@@ -22,22 +22,25 @@
<div> <div>
<div> <div>
<h1 class="logo-name">JumpServer</h1> <h1 class="logo-name"><img src="/static/img/logo.png"></h1>
</div> </div>
<h3>Welcome to JumpServer</h3> {% if error %}
<form class="m-t" role="form" method="post" action="/login/"> <div class="alert alert-danger text-center">{{ error }}</div>
{% endif %}
<h2>Welcome to JumpServer</h2>
<form class="m-t" role="form" method="post" action="">
<div class="form-group"> <div class="form-group">
<input type="email" class="form-control" placeholder="Username" required=""> <input type="text" name="username" class="form-control" placeholder="Username" required="length[6~50]">
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="password" class="form-control" placeholder="Password" required=""> <input type="password" name="password" class="form-control" placeholder="Password" required="">
</div> </div>
<button type="submit" class="btn btn-primary block full-width m-b">Login</button> <button type="submit" class="btn btn-primary block full-width m-b">Login</button>
<a href="#"><small>Forgot password?</small></a> <a href="#"><small>Forgot password?</small></a>
</form> </form>
<p class="m-t"> <small>Inspinia we app framework base on Bootstrap 3 &copy; 2014</small> </p> <p class="m-t"> <small><b>Copyright</b> Jumpserver.org Organization © 2014-2015</small> </p>
</div> </div>
</div> </div>
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
<li id="jperm"> <li id="jperm">
<a href="#"><i class="fa fa-edit"></i> <span class="nav-label">授权管理</span><span class="fa arrow"></span></a> <a href="#"><i class="fa fa-edit"></i> <span class="nav-label">授权管理</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level"> <ul class="nav nav-second-level">
<li><a href="/jperm/perm_list/">主机授权</a></li> <li id="perm_list"><a href="/jperm/perm_list/">主机授权</a></li>
<li><a href="/jperm/perm_sudo/">Sudo授权</a></li> <li id="perm_sudo"><a href="/jperm/perm_sudo/">Sudo授权</a></li>
</ul> </ul>
</li> </li>
<li id="jlog"> <li id="jlog">
......
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
</li> </li>
<li> <li>
<a href="login.html"> <a href="/logout/">
<i class="fa fa-sign-out"></i> Log out <i class="fa fa-sign-out"></i> Log out
</a> </a>
</li> </li>
......
...@@ -10,10 +10,11 @@ ...@@ -10,10 +10,11 @@
<li><a href="contacts.html">Contacts</a></li> <li><a href="contacts.html">Contacts</a></li>
<li><a href="mailbox.html">Mailbox</a></li> <li><a href="mailbox.html">Mailbox</a></li>
<li class="divider"></li> <li class="divider"></li>
<li><a href="login.html">Logout</a></li> <li><a href="/logout/">Logout</a></li>
</ul> </ul>
</div> </div>
<div class="logo-element"> <div class="logo-element">
JS+ JS+
</div> </div>
</li> </li>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment