mirror of https://github.com/jumpserver/jumpserver
change role finished , but need more think
parent
4d3e7d694b
commit
ac5ac5e06b
|
@ -217,12 +217,12 @@ def Login(request):
|
|||
# if PyCrypt.md5_crypt(password) == user.password:
|
||||
# request.session['user_id'] = user.id
|
||||
# user_filter.update(last_login=datetime.datetime.now())
|
||||
# if user.role == 'SU':
|
||||
# request.session['role_id'] = 2
|
||||
# elif user.role == 'GA':
|
||||
# request.session['role_id'] = 1
|
||||
# else:
|
||||
# request.session['role_id'] = 0
|
||||
if user.role == 'SU':
|
||||
request.session['role_id'] = 2
|
||||
elif user.role == 'GA':
|
||||
request.session['role_id'] = 1
|
||||
else:
|
||||
request.session['role_id'] = 0
|
||||
return HttpResponseRedirect('/', )
|
||||
# response.set_cookie('username', username, expires=604800)
|
||||
# response.set_cookie('seed', PyCrypt.md5_crypt(password), expires=604800)
|
||||
|
|
|
@ -22,6 +22,6 @@ urlpatterns = patterns('juser.views',
|
|||
(r'^profile/$', 'profile'),
|
||||
(r'^change_info/$', 'change_info'),
|
||||
(r'^regen_ssh_key/$', 'regen_ssh_key'),
|
||||
(r'^chg_role/$', 'chg_role'),
|
||||
(r'^change_role/$', 'chg_role'),
|
||||
(r'^down_key/$', 'down_key'),
|
||||
)
|
||||
|
|
|
@ -14,14 +14,11 @@ from juser.user_api import *
|
|||
|
||||
|
||||
def chg_role(request):
|
||||
# TODO: disable it! by liuzheng
|
||||
role = {'SU': 2, 'GA': 1, 'CU': 0}
|
||||
user, dept = get_session_user_dept(request)
|
||||
# TODO: liuzheng's work
|
||||
if request.session['role_id'] > 0:
|
||||
request.session['role_id'] = 0
|
||||
elif request.session['role_id'] == 0:
|
||||
request.session['role_id'] = role.get(user.role, 0)
|
||||
request.session['role_id'] = role.get(request.user.role, 0)
|
||||
return HttpResponseRedirect('/')
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% ifequal session_role_id 2 %}
|
||||
{% if request.session.role_id == 2 %}
|
||||
<nav class="navbar-default navbar-static-side" role="navigation">
|
||||
<div class="sidebar-collapse">
|
||||
<ul class="nav" id="side-menu">
|
||||
|
@ -51,8 +51,8 @@
|
|||
|
||||
</div>
|
||||
</nav>
|
||||
{% endifequal %}
|
||||
{% ifequal session_role_id 1 %}
|
||||
{% endif %}
|
||||
{% if request.session.role_id == 1 %}
|
||||
<nav class="navbar-default navbar-static-side" role="navigation">
|
||||
<div class="sidebar-collapse">
|
||||
<ul class="nav" id="side-menu">
|
||||
|
@ -103,9 +103,9 @@
|
|||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
{% endifequal %}
|
||||
{% endif %}
|
||||
|
||||
{% ifequal session_role_id 0 %}
|
||||
{% if request.session.role_id == 0 %}
|
||||
<nav class="navbar-default navbar-static-side" role="navigation">
|
||||
<div class="sidebar-collapse">
|
||||
<ul class="nav" id="side-menu">
|
||||
|
@ -144,4 +144,4 @@
|
|||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
{% endifequal %}
|
||||
{% endif %}
|
|
@ -17,8 +17,13 @@
|
|||
<ul class="dropdown-menu animated fadeInRight m-t-xs">
|
||||
<li><a value="/juser/profile/?id={{ session_user_id }}" class="iframe_user">个人信息</a></li>
|
||||
<li><a href="/juser/change_info/">修改信息</a></li>
|
||||
<li><a href="/juser/change_role/">切换角色</a></li>
|
||||
|
||||
{% if not user.role == 'CU' %}
|
||||
{% if request.session.role_id == 0 %}
|
||||
<li><a href="/juser/change_role/">系统后台</a></li>
|
||||
{% else %}
|
||||
<li><a href="/juser/change_role/">主机控制台</a></li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<li class="divider"></li>
|
||||
<li><a href="/logout/">注销</a></li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue