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
9142b8ff
authored
2022-05-18 16:14:19 +0800
by
周伟奇
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
admin test9
1 parent
8aeefa07
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
25 deletions
src/apps/account/urls.py
src/apps/account/views.py
src/apps/myadmin/admin.py
src/apps/account/urls.py
View file @
9142b8f
...
...
@@ -6,5 +6,5 @@ urlpatterns = [
path
(
r'login/'
,
views
.
LoginView
.
as_view
()),
path
(
r'iwalogin/'
,
views
.
IWALoginView
.
as_view
()),
path
(
r'iwaurl/'
,
views
.
IWAUrlView
.
as_view
()),
path
(
r'
testlogin/'
,
views
.
Test
View
.
as_view
()),
path
(
r'
adminlogin/'
,
views
.
AdminLogin
View
.
as_view
()),
]
...
...
src/apps/account/views.py
View file @
9142b8f
...
...
@@ -56,27 +56,24 @@ class LoginView(ObtainJSONWebToken, GenericView):
class
IWALoginView
(
IWABaseView
,
GenericView
):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
# code = request.data.get('code', '')
is_admin
=
request
.
data
.
get
(
'state'
,
''
)
==
'admin'
# q_number = self.get_q_number(conf.IWA_URL, code, conf.IWA_REDIRECT_URI, client_id_base64)
q_number
=
'admin'
if
is_admin
:
self
.
running_log
.
info
(
'[admin_users.iwalogin] [username: {0}] [params: {1}]'
.
format
(
q_number
,
request
.
data
))
is_valid
,
data
=
self
.
validate_admin
(
q_number
)
if
is_valid
:
request
.
user
=
data
auth_login
(
request
,
data
)
code
=
request
.
data
.
get
(
'code'
,
''
)
# is_admin = request.data.get('state', '') == 'admin'
q_number
=
self
.
get_q_number
(
conf
.
IWA_URL
,
code
,
conf
.
IWA_REDIRECT_URI
,
client_id_base64
)
# if is_admin:
#
# self.running_log.info('[admin_users.iwalogin] [username: {0}] [params: {1}]'.format(q_number, request.data))
#
# is_valid, data = self.validate_admin(q_number)
#
# if is_valid:
# request.user = data
# auth_login(request, data)
# index_path = reverse('admin:index')
# return HttpResponseRedirect(index_path)
return
redirect
(
'https://staging-bmw-ocr.situdata.com/admin/'
)
else
:
self
.
no_permission
(
data
)
else
:
# else:
# self.no_permission(data)
# else:
self
.
running_log
.
info
(
'[users.iwalogin] [username: {0}] [params: {1}]'
.
format
(
q_number
,
request
.
data
))
...
...
@@ -97,12 +94,13 @@ class IWAUrlView(IWABaseView, GenericView):
return
response
.
ok
(
data
=
data
)
class
Test
View
(
IWABaseView
,
GenericView
):
class
AdminLogin
View
(
IWABaseView
,
GenericView
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
#
code = request.data.get('code', '')
#
is_admin = request.data.get('state', '') == 'admin'
code
=
request
.
data
.
get
(
'code'
,
''
)
is_admin
=
request
.
data
.
get
(
'state'
,
''
)
==
'admin'
# q_number = self.get_q_number(conf.IWA_URL, code, conf.IWA_REDIRECT_URI, client_id_base64)
self
.
running_log
.
info
(
'code={0}, is_admin={1}'
.
format
(
code
,
is_admin
))
q_number
=
'admin'
...
...
@@ -115,6 +113,5 @@ class TestView(IWABaseView, GenericView):
auth_login
(
request
,
data
)
index_path
=
reverse
(
'admin:index'
)
return
HttpResponseRedirect
(
index_path
)
# return redirect('https://staging-bmw-ocr.situdata.com/admin/')
else
:
self
.
no_permission
(
data
)
...
...
src/apps/myadmin/admin.py
View file @
9142b8f
...
...
@@ -27,7 +27,7 @@ class MyAdminSite(admin.AdminSite):
index_path
=
reverse
(
'admin:index'
,
current_app
=
self
.
name
)
return
HttpResponseRedirect
(
index_path
)
# return HttpResponseRedirect(iwa_admin_url)
return
HttpResponseRedirect
(
'https://staging-bmw-ocr.situdata.com/
login
?state=admin&code=xxx'
)
return
HttpResponseRedirect
(
'https://staging-bmw-ocr.situdata.com/
api/user/adminlogin/
?state=admin&code=xxx'
)
admin_site
=
MyAdminSite
()
...
...
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