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
f249d538
Commit
f249d538
authored
Jan 11, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ok finished debugging redirects with next
parent
49310fcf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
main.py
services/main.py
+10
-8
No files found.
services/main.py
View file @
f249d538
...
...
@@ -29,7 +29,7 @@ from re import sub
from
os
import
path
from
json
import
dumps
from
datetime
import
timedelta
from
urllib.parse
import
urlparse
,
urljoin
from
urllib.parse
import
urlparse
,
urljoin
,
unquote
from
traceback
import
format_tb
from
flask
import
Flask
,
render_template
,
request
,
\
redirect
,
url_for
,
session
...
...
@@ -61,9 +61,6 @@ app = Flask("services",
static_folder
=
path
.
join
(
config
[
'HOME'
],
"static"
),
template_folder
=
path
.
join
(
config
[
'HOME'
],
"templates"
))
if
not
app
.
config
[
'SERVER_NAME'
]:
app
.
config
[
'SERVER_NAME'
]
=
"localhost"
app
.
config
[
'DEBUG'
]
=
(
config
[
'LOG_LEVEL'
]
==
"DEBUG"
)
app
.
config
[
'SECRET_KEY'
]
=
'TODO fill secret key for sessions for login'
...
...
@@ -280,16 +277,21 @@ def login():
next_url
=
request
.
args
.
get
(
'next'
,
None
)
if
next_url
:
print
(
"next_url"
,
next_url
)
print
(
"app.config.servername"
,
app
.
config
[
'SERVER_NAME'
]
)
next_url
=
unquote
(
next_url
)
mlog
(
"DEBUG"
,
"login with next_url:"
,
next_url
)
safe_flag
=
is_safe_url
(
next_url
,
request
.
host_url
)
# normal next_url
if
safe_flag
:
# normal next_url
# if relative
if
next_url
[
0
]
==
'/'
:
next_url
=
url_for
(
'rootstub'
,
_external
=
True
)
+
next_url
mlog
(
"INFO"
,
"reabsoluted next_url:"
,
next_url
[
1
:])
return
(
redirect
(
next_url
))
else
:
# server name is different than ours
# in next_url so we won't go there
return
(
redirect
(
'/'
))
return
(
redirect
(
url_for
(
'rootstub'
,
_external
=
True
)
))
else
:
# no specified next_url => profile
return
redirect
(
url_for
(
'profile'
,
_external
=
True
))
...
...
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