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
875aaa00
Commit
875aaa00
authored
Dec 20, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update user model for create application user
parent
589b6d7c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
2 deletions
+17
-2
user.py
apps/users/models/user.py
+14
-2
config_example.py
config_example.py
+3
-0
No files found.
apps/users/models/user.py
View file @
875aaa00
...
...
@@ -7,6 +7,7 @@ from collections import OrderedDict
from
django.contrib.auth.hashers
import
make_password
from
django.contrib.auth.models
import
AbstractUser
from
django.core
import
signing
from
django.conf
import
settings
from
django.db
import
models
,
IntegrityError
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils
import
timezone
...
...
@@ -14,7 +15,7 @@ from django.shortcuts import reverse
from
rest_framework.authtoken.models
import
Token
from
common.utils
import
signer
,
date_expired_default
from
.
import
UserGroup
from
.
import
UserGroup
,
AccessKey
__all__
=
[
'User'
]
...
...
@@ -24,7 +25,7 @@ class User(AbstractUser):
ROLE_CHOICES
=
(
(
'Admin'
,
_
(
'Administrator'
)),
(
'User'
,
_
(
'User'
)),
(
'A
PP
'
,
_
(
'Application'
))
(
'A
pp
'
,
_
(
'Application'
))
)
username
=
models
.
CharField
(
max_length
=
20
,
unique
=
True
,
verbose_name
=
_
(
'Username'
))
...
...
@@ -45,6 +46,8 @@ class User(AbstractUser):
verbose_name
=
_
(
'Date expired'
))
created_by
=
models
.
CharField
(
max_length
=
30
,
default
=
''
,
verbose_name
=
_
(
'Created by'
))
@property
def
password_raw
(
self
):
raise
AttributeError
(
'Password raw is not a readable attribute'
)
...
...
@@ -173,6 +176,15 @@ class User(AbstractUser):
'date_expired'
:
self
.
date_expired
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
})
@classmethod
def
create_app_user
(
cls
,
name
,
comment
):
domain_name
=
settings
.
DOMAIN_NAME
or
'jumpserver.org'
app
=
cls
.
objects
.
create
(
username
=
name
,
name
=
name
,
email
=
'
%
s@
%
s'
%
(
name
,
domain_name
),
role
=
'App'
,
enable_otp
=
False
,
comment
=
comment
,
is_first_login
=
False
,
created_by
=
'System'
)
AccessKey
.
object
.
create
(
user
=
app
)
return
app
@classmethod
def
validate_reset_token
(
cls
,
token
):
try
:
...
...
config_example.py
View file @
875aaa00
...
...
@@ -26,6 +26,9 @@ class Config:
# HTTP_PROTOCOL://HOST[:PORT]
SITE_URL
=
'http://localhost'
# Domain name, If set app email will set as it
DOMAIN_NAME
=
'jumpserver.org'
# Django security setting, if your disable debug model, you should setting that
ALLOWED_HOSTS
=
[
'*'
]
...
...
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