mirror of https://github.com/jumpserver/jumpserver
Ð޸ĵǽÍ˳ö
parent
35d9be5c10
commit
c1fb72f393
|
@ -8,6 +8,8 @@ urlpatterns = patterns('',
|
|||
(r'^$', 'jumpserver.views.base'),
|
||||
(r'^skin_config/$', 'jumpserver.views.skin_config'),
|
||||
(r'^base/$', 'jumpserver.views.base'),
|
||||
(r'^login/$', 'jumpserver.views.login'),
|
||||
(r'^logout/$', 'jumpserver.views.logout'),
|
||||
(r'^juser/', include('juser.urls')),
|
||||
(r'^jperm/', include('jperm.urls')),
|
||||
url(r'^jasset/', include('jasset.urls')),
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
#coding: utf-8
|
||||
|
||||
import hashlib
|
||||
|
||||
from django.http import HttpResponse
|
||||
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):
|
||||
|
@ -12,3 +21,36 @@ def skin_config(request):
|
|||
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:
|
|||
LDAP_ROOT_PW = CONF.get('ldap', 'root_pw')
|
||||
|
||||
|
||||
def md5_crypt(string):
|
||||
return hashlib.new("md5", string).hexdigest()
|
||||
|
||||
|
||||
def gen_rand_pwd(num):
|
||||
"""生æˆéšæœºå¯†ç """
|
||||
seed = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<link rel="shortcut icon" href="/static/img/facio.ico" type="image/x-icon">
|
||||
{% include 'link_css.html' %}
|
||||
{% include 'script.html' %}
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!--{% include 'script.html' %}-->
|
||||
{# <!--{% include 'script.html' %}-->#}
|
||||
</body>
|
||||
|
||||
{% include 'script.html' %}
|
||||
</html>
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<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">
|
||||
<input id="email" name="email" type="email" placeholder="Email" class="form-control" value="{{ email }}">
|
||||
</div>
|
||||
|
@ -191,6 +191,12 @@ $('#userForm').validator({
|
|||
ok: "",
|
||||
msg: {required: "必须填写"}
|
||||
},
|
||||
"email": {
|
||||
rule: "required",
|
||||
tip: "Email",
|
||||
ok: "",
|
||||
msg: {required: "必须填写"}
|
||||
},
|
||||
"role": {
|
||||
rule: "checked",
|
||||
tip: "角色",
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<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/font-awesome/css/font-awesome.css" rel="stylesheet">
|
||||
|
||||
|
@ -22,22 +22,25 @@
|
|||
<div>
|
||||
<div>
|
||||
|
||||
<h1 class="logo-name">JumpServer</h1>
|
||||
<h1 class="logo-name"><img src="/static/img/logo.png"></h1>
|
||||
|
||||
</div>
|
||||
<h3>Welcome to JumpServer</h3>
|
||||
<form class="m-t" role="form" method="post" action="/login/">
|
||||
{% if error %}
|
||||
<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">
|
||||
<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 class="form-group">
|
||||
<input type="password" class="form-control" placeholder="Password" required="">
|
||||
<input type="password" name="password" class="form-control" placeholder="Password" required="">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary block full-width m-b">Login</button>
|
||||
|
||||
<a href="#"><small>Forgot password?</small></a>
|
||||
</form>
|
||||
<p class="m-t"> <small>Inspinia we app framework base on Bootstrap 3 © 2014</small> </p>
|
||||
<p class="m-t"> <small><b>Copyright</b> Jumpserver.org Organization © 2014-2015</small> </p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
<li id="jperm">
|
||||
<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">
|
||||
<li><a href="/jperm/perm_list/">主机授æƒ</a></li>
|
||||
<li><a href="/jperm/perm_sudo/">Sudo授æƒ</a></li>
|
||||
<li id="perm_list"><a href="/jperm/perm_list/">主机授æƒ</a></li>
|
||||
<li id="perm_sudo"><a href="/jperm/perm_sudo/">Sudo授æƒ</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li id="jlog">
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
</li>
|
||||
|
||||
<li>
|
||||
<a href="login.html">
|
||||
<a href="/logout/">
|
||||
<i class="fa fa-sign-out"></i> Log out
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -10,10 +10,11 @@
|
|||
<li><a href="contacts.html">Contacts</a></li>
|
||||
<li><a href="mailbox.html">Mailbox</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="login.html">Logout</a></li>
|
||||
<li><a href="/logout/">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="logo-element">
|
||||
JS+
|
||||
</div>
|
||||
</li>
|
||||
|
||||
|
|
Loading…
Reference in New Issue