Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
0f18e702
Commit
0f18e702
authored
Sep 16, 2014
by
guanghongwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改保存
parent
63cdef42
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
5 deletions
+10
-5
views.py
webroot/AutoSa/AutoSa/views.py
+8
-3
models.py
webroot/AutoSa/UserManage/models.py
+2
-2
No files found.
webroot/AutoSa/AutoSa/views.py
View file @
0f18e702
...
@@ -4,14 +4,13 @@ from django.http import HttpResponse
...
@@ -4,14 +4,13 @@ from django.http import HttpResponse
from
django.template
import
RequestContext
from
django.template
import
RequestContext
from
django.shortcuts
import
render_to_response
from
django.shortcuts
import
render_to_response
from
django.http
import
HttpResponseRedirect
from
django.http
import
HttpResponseRedirect
from
UserManage.models
import
User
from
UserManage.models
import
User
,
Group
from
Assets.models
import
Assets
,
AssetsUser
from
Assets.models
import
Assets
,
AssetsUser
import
subprocess
import
subprocess
from
Crypto.Cipher
import
AES
from
Crypto.Cipher
import
AES
from
binascii
import
b2a_hex
,
a2b_hex
from
binascii
import
b2a_hex
,
a2b_hex
import
random
import
random
import
ConfigParser
import
ConfigParser
import
pam
from
UserManage.forms
import
UserAddForm
,
GroupAddForm
from
UserManage.forms
import
UserAddForm
,
GroupAddForm
...
@@ -176,16 +175,22 @@ def addUser(request):
...
@@ -176,16 +175,22 @@ def addUser(request):
if
form
.
is_valid
():
if
form
.
is_valid
():
user
=
form
.
cleaned_data
user
=
form
.
cleaned_data
ldap_password
=
keygen
(
16
)
ldap_password
=
keygen
(
16
)
group_post
=
user
[
'group'
]
groups
=
[]
for
group_name
in
group_post
:
groups
.
append
(
Group
.
objects
.
get
(
name
=
group_name
))
u
=
User
(
u
=
User
(
username
=
user
[
'username'
],
username
=
user
[
'username'
],
password
=
user
[
'password'
],
password
=
user
[
'password'
],
key_pass
=
user
[
'key_pass'
],
key_pass
=
user
[
'key_pass'
],
name
=
user
[
'name'
],
name
=
user
[
'name'
],
group
=
user
[
'group'
],
is_admin
=
user
[
'is_admin'
],
is_admin
=
user
[
'is_admin'
],
is_superuser
=
user
[
'is_superuser'
],
is_superuser
=
user
[
'is_superuser'
],
ldap_password
=
ldap_password
)
ldap_password
=
ldap_password
)
u
.
save
()
u
.
save
()
u
.
group
=
groups
u
.
save
()
return
render_to_response
(
'addUser.html'
,
{
'msg'
:
msg
,
'user_menu'
:
'active'
},
return
render_to_response
(
'addUser.html'
,
{
'msg'
:
msg
,
'user_menu'
:
'active'
},
context_instance
=
RequestContext
(
request
))
context_instance
=
RequestContext
(
request
))
...
...
webroot/AutoSa/UserManage/models.py
View file @
0f18e702
...
@@ -2,14 +2,14 @@ from django.db import models
...
@@ -2,14 +2,14 @@ from django.db import models
class
Group
(
models
.
Model
):
class
Group
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
name
=
models
.
CharField
(
max_length
=
50
,
unique
=
True
)
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
self
.
name
return
self
.
name
class
User
(
models
.
Model
):
class
User
(
models
.
Model
):
username
=
models
.
CharField
(
max_length
=
50
)
username
=
models
.
CharField
(
max_length
=
50
,
unique
=
True
)
password
=
models
.
CharField
(
max_length
=
100
)
password
=
models
.
CharField
(
max_length
=
100
)
key_pass
=
models
.
CharField
(
max_length
=
100
)
key_pass
=
models
.
CharField
(
max_length
=
100
)
name
=
models
.
CharField
(
max_length
=
50
)
name
=
models
.
CharField
(
max_length
=
50
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment