Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
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
david Chavalarias
clinicaltrials
Commits
ea907374
Commit
ea907374
authored
Jan 31, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use X-Requested-With to clearly identify api calls
parent
937dff16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
main.py
services/main.py
+5
-4
comex_lib_elts.js
static/js/comex_lib_elts.js
+1
-0
No files found.
services/main.py
View file @
ea907374
...
...
@@ -247,10 +247,9 @@ def login():
elif
request
.
method
==
'POST'
:
mlog
(
"DEBUG"
,
"login form received from "
+
request
.
path
+
", with keys:"
,
[
k
for
k
in
request
.
values
])
called_as_api
=
False
if
request
.
path
!=
config
[
'PREFIX'
]
+
config
[
'USR_ROUTE'
]
+
'/login/'
:
# the referer is another page
called_as_api
=
True
# we used this custom header to mark ajax calls => called_as_api True
x_req_with
=
request
.
headers
.
get
(
'X-Requested-With'
,
type
=
str
)
called_as_api
=
(
x_req_with
in
[
'XMLHttpRequest'
,
'MyFetchRequest'
])
# testing the captcha answer
captcha_userinput
=
request
.
form
[
'my-captcha'
]
...
...
@@ -283,6 +282,8 @@ def login():
mlog
(
"ERROR"
,
"error in doors_login request"
)
raise
(
err
)
mlog
(
"DEBUG"
,
"doors_login returned id '
%
s'"
%
doors_uid
)
luid
=
doors_uid_to_luid
(
doors_uid
)
if
luid
:
...
...
static/js/comex_lib_elts.js
View file @
ea907374
...
...
@@ -65,6 +65,7 @@ var cmxClt = (function(cC) {
if
(
window
.
fetch
)
{
fetch
(
'/services/user/login/'
,
{
method
:
'POST'
,
headers
:
{
'X-Requested-With'
:
'MyFetchRequest'
},
body
:
formdat
,
credentials
:
"same-origin"
// <= this allows response's Set-Cookie
})
...
...
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