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
934f1520
Commit
934f1520
authored
Jan 27, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP create login becomes more autonomous (Merge with stashed progress)
parent
e27e8117
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
62 deletions
+82
-62
main.py
services/main.py
+23
-16
user.py
services/user.py
+3
-4
comex.css
static/css/comex.css
+16
-0
whoswho.css
static/css/whoswho.css
+1
-0
comex_user_shared_auth.js
static/js/comex_user_shared_auth.js
+35
-32
base_layout.html
templates/base_layout.html
+4
-10
No files found.
services/main.py
View file @
934f1520
...
...
@@ -122,11 +122,19 @@ SOURCE_FIELDS = [
# mandatory minimum of keywords # TODO use
MIN_KW
=
5
# ============= views =============
# ============= context =============
@
app
.
context_processor
def
inject_doors_params
():
"""
Keys will be available in *all* templates
-> 'doors_connect'
(base_layout-rendered templates need it for login popup)
"""
return
dict
(
doors_connect
=
config
[
'DOORS_HOST'
]
+
':'
+
config
[
'DOORS_PORT'
]
)
# -----------------------------------------------------------------------
# /!\ Routes are not prefixed by nginx in prod so we do it ourselves /!\
# -----------------------------------------------------------------------
@
login_manager
.
unauthorized_handler
def
unauthorized
():
...
...
@@ -147,6 +155,12 @@ def unauthorized():
)
# ============= views =============
# -----------------------------------------------------------------------
# /!\ Routes are not prefixed by nginx in prod so we do it ourselves /!\
# -----------------------------------------------------------------------
@
app
.
route
(
"/"
)
def
rootstub
():
"""
...
...
@@ -229,8 +243,7 @@ def user():
def
login
():
if
request
.
method
==
'GET'
:
return
render_template
(
"login.html"
,
doors_connect
=
config
[
'DOORS_HOST'
]
+
':'
+
config
[
'DOORS_PORT'
]
"login.html"
)
elif
request
.
method
==
'POST'
:
# testing the captcha answer
...
...
@@ -328,8 +341,7 @@ def logout():
@
app
.
route
(
'/test_base'
)
def
test_base
():
return
render_template
(
"base_layout.html"
,
doors_connect
=
config
[
'DOORS_HOST'
]
+
':'
+
config
[
'DOORS_PORT'
]
"base_layout.html"
)
...
...
@@ -363,11 +375,7 @@ def profile():
mlog
(
"DEBUG"
,
"PROFILE view with flag session.new = "
,
session
.
new
)
return
render_template
(
"profile.html"
,
# doors info only for link
doors_connect
=
config
[
'DOORS_HOST'
]
+
':'
+
config
[
'DOORS_PORT'
]
"profile.html"
# NB we also got user info in {{current_user.info}}
# and {{current_user.json_info}}
)
...
...
@@ -418,9 +426,8 @@ def register():
if
request
.
method
==
'GET'
:
return
render_template
(
"registration_short_form.html"
,
doors_connect
=
config
[
'DOORS_HOST'
]
+
':'
+
config
[
'DOORS_PORT'
]
)
"registration_short_form.html"
)
elif
request
.
method
==
'POST'
:
# ex: request.form = ImmutableMultiDict([('initials', 'R.L.'), ('email', 'romain.loth@iscpif.fr'), ('last_name', 'Loth'), ('country', 'France'), ('first_name', 'Romain'), ('my-captchaHash', '-773776109'), ('my-captcha', 'TSZVIN')])
# mlog("DEBUG", "GOT ANSWERS <<========<<", request.form)
...
...
services/user.py
View file @
934f1520
...
...
@@ -90,7 +90,7 @@ def jsonize_uinfo(uinfo_dict):
# most fields are already serializable
serializable_dict
=
{
k
:
v
for
k
,
v
in
uinfo_dict
.
items
()
if
k
not
in
[
'pic_file'
,
'valid_date'
]}
if
'pic_file'
in
uinfo_dict
and
len
(
uinfo_dict
[
'pic_file'
]):
if
'pic_file'
in
uinfo_dict
and
type
(
uinfo_dict
[
'pic_file'
])
==
bytes
and
len
(
uinfo_dict
[
'pic_file'
]):
serializable_dict
[
'pic_file'
]
=
"<blob_not_copied>"
if
'valid_date'
in
uinfo_dict
and
uinfo_dict
[
'valid_date'
]
is
not
None
:
...
...
@@ -171,9 +171,8 @@ class User(object):
@
property
def
is_authenticated
(
self
):
"""
TODO choose strategy
- assume user object only exists if user was authenticated
- or re-test each time with doors?
We assume user object only exists if user was authenticated or has cookie
POSS: re-test each time with doors
"""
return
True
...
...
static/css/comex.css
View file @
934f1520
...
...
@@ -31,6 +31,22 @@ body {
*/
}
/* just like bs "topbar > li.dropdown > a" but planned for divs with onclick */
.dropdown-a-like
{
font-size
:
14px
;
clear
:
both
;
padding
:
4px
15px
;
color
:
#999
;
line-height
:
18px
;
text-shadow
:
0
1px
0
rgba
(
0
,
0
,
0
,
0.5
);
cursor
:
pointer
;
}
.dropdown-a-like
:hover
{
background-color
:
#191919
;
background-image
:
linear-gradient
(
top
,
#292929
,
#191919
);
color
:
#fff
;
}
/* main content for all new pages */
div
.my-box
{
padding
:
0
20px
;
...
...
static/css/whoswho.css
View file @
934f1520
...
...
@@ -154,6 +154,7 @@ input.name {
height
:
35px
;
font-size
:
29px
;
width
:
290px
;
padding
:
4px
6px
;
}
@media
(
max-width
:
544px
){
...
...
static/js/comex_user_shared_auth.js
View file @
934f1520
...
...
@@ -69,7 +69,7 @@ cmxClt = (function(cC) {
// mode <=> 'login' or 'register'
if
(
boxParams
.
mode
==
undefined
)
boxParams
.
mode
=
'login'
// for prefilled values
if
(
boxParams
.
email
==
undefined
)
boxParams
.
email
=
null
if
(
boxParams
.
email
==
undefined
)
boxParams
.
email
=
""
// add a captcha ?
if
(
boxParams
.
doCaptcha
==
undefined
)
boxParams
.
doCaptcha
=
false
...
...
@@ -91,7 +91,7 @@ cmxClt = (function(cC) {
}
else
if
(
boxParams
.
mode
==
'login'
)
{
title
=
"Login via the Doors portal"
preEmail
=
boxParams
.
email
||
''
preEmail
=
boxParams
.
email
emailLegend
=
"This email is your login for both community explorer and the institute's authentication portal 'Doors'"
passLegend
=
""
confirmPass
=
""
...
...
@@ -124,15 +124,15 @@ cmxClt = (function(cC) {
<div class="modal fade self-made" id="auth_modal" role="dialog" aria-labelledby="authTitle" aria-hidden="true" style="display:none">
<div class="modal-dialog" role="document">
<div class="modal-content">
<
div class="modal-header">
<button type="button" class="close" onclick="cC.uauth.box.toggleAuthBox()" aria-label="Close
">
<
span aria-hidden="true">×</span
>
</button
>
<h5 class="modal-title" id="authTitle">
${
title
}
</h5
>
</div
>
<div class="modal-body auth-box"
>
<form id="auth_box" enctype="multipart/form-data"
method="post" onsubmit="console.info('auth_box submitted')
">
<
form id="auth_box" enctype="multipart/form-data"
method="post" onsubmit="console.info('auth_box submitted')
">
<
div class="modal-header"
>
<button type="button" class="close" onclick="cC.uauth.box.toggleAuthBox()" aria-label="Close"
>
<span aria-hidden="true">×</span
>
</button
>
<h5 class="modal-title" id="authTitle">
${
title
}
</h5
>
</div>
<div class="modal-body
">
<div class="question">
<p class="legend">
${
emailLegend
}
</p>
<div class="input-group">
...
...
@@ -166,17 +166,17 @@ cmxClt = (function(cC) {
${
confirmPass
}
<br/>
${
captchaBlock
}
</form
>
</div
>
<div class="modal-footer"
>
<button type="button" class="btn btn-secondary" onclick='cC.uauth.box.toggleAuthBox()'>
Cancel
</button>
<button type="submit" id="form_submit"
class="btn btn-primary">
Submit
</button
>
</
div
>
</div
>
<div class="modal-footer"
>
<button type="button" class="btn btn-secondary" onclick='cC.uauth.box.toggleAuthBox()'
>
Cancel
</button>
<button type="submit" id="menu_form_submit"
class="btn btn-primary">
Submit
</button>
</div
>
</
form
>
</div>
</div>
</div>`
...
...
@@ -191,21 +191,23 @@ cmxClt = (function(cC) {
}
//
if not there, add the box in all pages ( => allows login via menu )
//
add the box in all pages ( => allows login via menu ) ---
// directly when there's no previous form
if
(
!
document
.
getElementById
(
'email'
))
{
cC
.
uauth
.
box
.
addAuthBox
({
'mode'
:
'login'
,
'doCaptcha'
:
fals
e
})
cC
.
uauth
.
box
.
addAuthBox
({
'mode'
:
'login'
,
'doCaptcha'
:
tru
e
})
// inserted html elements can now be identified by uauth:
// - cf. uauth.uidInput
// - cf. uauth.email and uauth.emailLbl
}
// /login box ----------------------------------------------------------
// TODO don't crowd uform values but still work with uauth
else
{
console
.
warn
(
'duplicate form case to fix'
)
cC
.
uauth
.
box
.
addAuthBox
({
'mode'
:
'login'
,
'doCaptcha'
:
true
})
}
// /login box ----------------------------------------------------------
cC
.
uauth
.
email
=
document
.
getElementById
(
'email'
)
cC
.
uauth
.
uidInput
=
document
.
getElementById
(
'doors_uid'
)
...
...
@@ -258,10 +260,11 @@ cmxClt = (function(cC) {
cC
.
uauth
.
checkPassFormat
()
}
// finally also update cC.uauth.captchaStatus if captcha present
// finally also update cC.uauth.captchaStatus
// (if captcha absent then false, to handle in caller)
cC
.
uauth
.
captchaStatus
=
(
!
cC
.
uauth
.
captcha
||
(
cC
.
uauth
.
captcha
.
value
.
length
==
cC
.
uauth
.
realCaptchaLength
)
cC
.
uauth
.
captcha
&&
(
cC
.
uauth
.
captcha
.
value
.
length
==
cC
.
uauth
.
realCaptchaLength
)
)
}
...
...
templates/base_layout.html
View file @
934f1520
...
...
@@ -158,7 +158,9 @@
<a
href=
"/services/user/register"
>
Register
</a>
</li>
<li>
<div
onclick=
"cmxClt.uauth.box.toggleAuthBox()"
>
Login
</div>
<div
class=
"dropdown-a-like"
id=
"poplogin"
onclick=
"cmxClt.uauth.box.toggleAuthBox()"
>
Login
</div>
</li>
{% endif %}
</ul>
...
...
@@ -219,15 +221,7 @@
<!-- our js for auth and login: to be able to login via popup anywhere -->
<script
src=
"{{ url_for('static', filename='js/comex_user_shared.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/comex_user_shared_auth.js') }}"
></script>
<script>
cmxClt
.
uauth
.
box
.
addAuthBox
({
'mode'
:
'login'
,
'doCaptcha'
:
false
})
console
.
info
(
"ok"
)
// inserted html elements can now be identified by uauth:
// - cf. uauth.uidInput
// - cf. uauth.email and uauth.emailLbl
</script>
<script
src=
"{{ url_for('static', filename='js/comex_page_login_controllers.js') }}"
></script>
<script
src=
"{{ url_for('static', filename='js/comex_menubar_login_controllers.js') }}"
></script>
<!-- for our other js: end-of-page javascript imports -->
{% block last_imports %}
...
...
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