Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
bmw-ocr
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
bf66043f
authored
2023-06-02 11:08:00 +0800
by
冯轩
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
init:3528
1 parent
c80aa3cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
src/apps/account/views.py
src/apps/doc/models.py
src/apps/account/views.py
View file @
bf66043
...
...
@@ -9,6 +9,7 @@ from settings import conf
from
django.urls
import
reverse
from
django.http
import
HttpResponseRedirect
from
django.contrib.auth
import
login
as
auth_login
from
apps.doc.models
import
UserRole
# from django.conf import settings
# from django.shortcuts import resolve_url, redirect
...
...
@@ -46,10 +47,12 @@ class LoginView(ObtainJSONWebToken, GenericView):
serializer
=
self
.
get_serializer
(
data
=
request
.
data
)
serializer
.
is_valid
()
user
=
serializer
.
object
.
get
(
'user'
)
user_role
=
UserRole
.
objects
.
filter
(
auth_user_id
=
user
.
id
)
.
first
()
data
=
{
'user_id'
:
user
.
id
,
'user_name'
:
user
.
username
,
'token'
:
res
.
data
.
get
(
'token'
),
'role'
:
user_role
.
role
if
user_role
else
-
1
}
rh
.
set_token
(
res
.
data
.
get
(
'token'
)[
-
10
:],
user
.
username
)
return
response
.
ok
(
data
=
data
)
...
...
@@ -83,6 +86,8 @@ class IWALoginView(IWABaseView, GenericView):
if
is_valid
:
rh
.
set_token
(
data
.
get
(
'token'
)[
-
10
:],
data
.
get
(
'user_name'
))
user_role
=
UserRole
.
objects
.
filter
(
auth_user_id
=
data
.
get
(
'user_id'
))
.
first
()
data
[
'role'
]
=
user_role
.
role
if
user_role
else
-
1
return
response
.
ok
(
data
=
data
)
else
:
self
.
no_permission
(
data
)
...
...
src/apps/doc/models.py
View file @
bf66043
...
...
@@ -1099,3 +1099,12 @@ class HILCmsStatusInfo(models.Model):
class
Meta
:
managed
=
False
db_table
=
'hil_cms_status_info'
class
UserRole
(
models
.
Model
):
id
=
models
.
AutoField
(
primary_key
=
True
,
verbose_name
=
"id"
)
# 主键
auth_user_id
=
models
.
SmallIntegerField
(
null
=
False
,
default
=
0
,
verbose_name
=
"auth_user_id"
)
role
=
models
.
SmallIntegerField
(
null
=
False
,
default
=
0
,
verbose_name
=
"role"
)
menu_list
=
models
.
CharField
(
max_length
=
64
,
verbose_name
=
"menu_list"
)
class
Meta
:
managed
=
False
db_table
=
'user_role'
\ No newline at end of file
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment