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
96aebc1b
Commit
96aebc1b
authored
Feb 22, 2017
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish create login in claim_profile scenario
parent
67848bf9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
133 additions
and
58 deletions
+133
-58
main.py
services/main.py
+57
-3
user.py
services/user.py
+4
-4
comex_page_claim_profile_controllers.js
static/js/comex_page_claim_profile_controllers.js
+3
-4
comex_user_shared_auth.js
static/js/comex_user_shared_auth.js
+58
-42
claim_profile.html
templates/claim_profile.html
+11
-5
No files found.
services/main.py
View file @
96aebc1b
...
...
@@ -41,7 +41,7 @@ if __package__ == 'services':
from
services
import
db
from
services
import
tools
from
services.tools
import
mlog
from
services.user
import
User
,
login_manager
,
doors_login
from
services.user
import
User
,
login_manager
,
doors_login
,
doors_register
from
services.db_to_tina_api.extractDataCustom
import
MyExtractor
# TODO move sanitize there
# from services.text import keywords, sanitize
...
...
@@ -51,7 +51,7 @@ else:
import
db
import
tools
from
tools
import
mlog
from
user
import
User
,
login_manager
,
doors_login
from
user
import
User
,
login_manager
,
doors_login
,
doors_register
from
db_to_tina_api.extractDataCustom
import
MyExtractor
# from text import keywords, sanitize
...
...
@@ -566,7 +566,61 @@ def claim_profile():
return_user
=
return_user
)
elif
request
.
method
==
'POST'
:
return
(
'not implemented yet'
)
email
=
request
.
form
[
'email'
]
pwd
=
request
.
form
[
'password'
]
luid
=
request
.
form
[
'return_user_luid'
]
return_user
=
User
(
luid
)
name
=
return_user
.
info
.
get
(
'last_name'
)
+
', '
+
return_user
.
info
.
get
(
'first_name'
,
''
)
+
' '
+
return_user
.
info
.
get
(
'middle_name'
,
''
)
# we do our doors request here server-side to avoid MiM attack on result
try
:
doors_uid
=
doors_register
(
email
,
pwd
,
name
,
config
)
except
Exception
as
err
:
mlog
(
"ERROR"
,
"error in doors_register remote request"
)
raise
(
err
)
mlog
(
"DEBUG"
,
"doors_register returned doors_uid '
%
s'"
%
doors_uid
)
if
doors_uid
is
None
:
return
render_template
(
"thank_you.html"
,
form_accepted
=
False
,
backend_error
=
True
,
debug_message
=
"No ID was returned from the portal at registration"
)
else
:
try
:
db_connection
=
db
.
connect_db
(
config
)
db
.
save_scholar
({
'doors_uid'
:
doors_uid
,
'record_status'
:
'active'
,
'valid_date'
:
None
},
db_connection
,
update_user
=
return_user
.
info
)
db_connection
.
close
()
# the user is not a legacy user anymore
# POSS: do this on first login instead
rm_legacy_user_rettoken
(
luid
)
except
Exception
as
perr
:
return
render_template
(
"thank_you.html"
,
form_accepted
=
False
,
backend_error
=
True
,
debug_message
=
tools
.
format_err
(
perr
)
)
return
render_template
(
"message.html"
,
message
=
"Your new login credentials are saved. To complete your registration, just click the link in the confirmation email you should receive."
)
# /services/user/register/
...
...
services/user.py
View file @
96aebc1b
...
...
@@ -201,7 +201,7 @@ class User(object):
from
requests
import
post
def
doors_login
(
email
,
password
,
config
):
def
doors_login
(
email
,
password
,
config
=
REALCONFIG
):
"""
Remote query to Doors API to login a user
...
...
@@ -276,6 +276,6 @@ def doors_register(email, password, name, config=REALCONFIG):
# eg doors_response.content = b'{"status":"registration email sent",
# "email":"john@locke.com"}''
answer
=
loads
(
doors_response
.
content
.
decode
())
return
(
doors_response
.
ok
and
(
answer
[
'status'
]
==
"RegistrationPending"
))
return
answer
else
:
return
None
static/js/comex_page_claim_profile_controllers.js
View file @
96aebc1b
...
...
@@ -84,9 +84,8 @@ var consultReturnDataUForm = cmxClt.uform.Form(
selectSavedMenus
(
uinfo
)
// 2 exposed vars for inline js controls
var
teamCityDivStyle
=
document
.
getElementById
(
'team_city_div'
).
style
var
otherInstDivStyle
=
document
.
getElementById
(
'other_org_div'
).
style
// 1 exposed vars for inline js controls
var
otherInstDiv
=
document
.
getElementById
(
'other_org_div'
)
// open middlename if there is one
...
...
@@ -105,7 +104,7 @@ var returnForm = cmxClt.uauth.AuthForm(
'comex_createlogin_form'
,
miniregValidate
,
{
'type'
:
"
r
egister"
,
'type'
:
"
doorsR
egister"
,
// if email validation, captcha perhaps too much?
'validateCaptcha'
:
false
}
...
...
static/js/comex_user_shared_auth.js
View file @
96aebc1b
...
...
@@ -42,7 +42,7 @@ cmxClt = (function(cC) {
// --------
// @id
// @params:
// - type login|register
// - type login|register
|doorsRegister
// - emailId html email input element id
// - duuidId html doors_uid hidden input element id
// - passId html password input element id
...
...
@@ -71,7 +71,7 @@ cmxClt = (function(cC) {
// -> interaction elements (params, else default)
var
emailId
,
duuidId
,
passId
,
pass2Id
,
captchaId
,
capcheckId
//
console.info('new AuthForm "'+auForm.id+'"[.type='+auForm.type+'] init params', afParams)
console
.
info
(
'new AuthForm "'
+
auForm
.
id
+
'"[.type='
+
auForm
.
type
+
'] init params'
,
afParams
)
emailId
=
afParams
.
emailId
||
'email'
duuidId
=
afParams
.
duuidId
||
'doors_uid'
...
...
@@ -102,14 +102,14 @@ cmxClt = (function(cC) {
// 2) for password
// login <=> just test password's length
if
(
auForm
.
type
!=
'register
'
)
{
if
(
auForm
.
type
==
'login
'
)
{
auForm
.
elPass
.
onkeyup
=
function
(
event
)
{
// console.debug("..elPass "+auForm.id+" event:"+event.type)
auForm
.
passStatus
=
(
auForm
.
elPass
.
value
.
length
>
7
)
}
auForm
.
elPass
.
onchange
=
auForm
.
elPass
.
onkeyup
}
// register <=> do pass 1 and pass 2 match?
// register
cases
<=> do pass 1 and pass 2 match?
else
{
// retrieve message element
auForm
.
pass2Dials
=
{}
...
...
@@ -128,30 +128,32 @@ cmxClt = (function(cC) {
// 3) for captcha
if
(
auForm
.
validateCaptcha
)
{
// NB this captcha init requires *jquery*
$
(
auForm
.
elCaptcha
).
realperson
(
{
length
:
cC
.
uauth
.
realCaptchaLength
}
)
// so... the events
auForm
.
elCaptcha
.
onkeyup
=
function
(
event
)
{
// console.debug('..elCaptcha '+auForm.id+' event:'+event.type)
auForm
.
captchaStatus
=
(
auForm
.
elCaptcha
.
value
.
length
==
cC
.
uauth
.
realCaptchaLength
)
if
(
auForm
.
elCaptcha
)
{
// NB this captcha init requires *jquery*
$
(
auForm
.
elCaptcha
).
realperson
(
{
length
:
cC
.
uauth
.
realCaptchaLength
}
)
// so... the events
auForm
.
elCaptcha
.
onkeyup
=
function
(
event
)
{
// console.debug('..elCaptcha '+auForm.id+' event:'+event.type)
auForm
.
captchaStatus
=
(
auForm
.
elCaptcha
.
value
.
length
==
cC
.
uauth
.
realCaptchaLength
)
}
auForm
.
elCaptcha
.
onchange
=
auForm
.
elCaptcha
.
onkeyup
// also form submit() overoverload
auForm
.
elForm
.
oldSubmitAction
=
auForm
.
elForm
.
submit
auForm
.
elForm
.
submit
=
function
()
{
// console.log("go newSubmit")
cmxClt
.
uauth
.
collectCaptcha
(
auForm
)
// console.log("go oldSubmit")
auForm
.
elForm
.
oldSubmitAction
()
}
}
auForm
.
elCaptcha
.
onchange
=
auForm
.
elCaptcha
.
onkeyup
// also form submit() overoverload
auForm
.
elForm
.
oldSubmitAction
=
auForm
.
elForm
.
submit
auForm
.
elForm
.
submit
=
function
()
{
// console.log("go newSubmit")
cmxClt
.
uauth
.
collectCaptcha
(
auForm
)
// console.log("go oldSubmit")
auForm
.
elForm
.
oldSubmitAction
()
else
{
console
.
warn
(
`validateCaptcha is set to true but there is no captcha in the authentication form #
${
auForm
.
id
}
`
)
}
}
else
{
console
.
log
(
"No captcha in auForm"
,
auForm
.
id
)
}
// return new obj
return
auForm
...
...
@@ -237,8 +239,9 @@ cmxClt = (function(cC) {
// NEW: added a user api check in register case
// if login <=> just callDoors
// if register <=> callUserApi and callDoors
// if type == login <=> just callDoors for an existing ID
// if type == register <=> callUserApi and callDoors for a new ID
// if type == doorsRegister <=> just callDoors for a new ID
// NB using route in doors api/userExists
// using route in comex api/user?op=exists
...
...
@@ -268,29 +271,40 @@ cmxClt = (function(cC) {
obja
.
lastEmailValue
=
emailValue
}
// similar but one chained call to local api
else
if
(
obja
.
type
==
"register"
)
{
else
if
(
obja
.
type
==
"register"
||
obja
.
type
==
"doorsRegister"
)
{
// email available on doors side
// -----------------------------
if
(
doorsMsg
==
(
"LoginAvailable"
))
{
// let's see if it's also available on comexdb side
cC
.
uauth
.
callUserApi
(
"exists"
,
emailValue
,
function
(
boolExists
)
{
obja
.
emailStatus
=
!
boolExists
var
guiMsg
=
boolExists
?
'login already taken in communityexplorer'
:
'login available'
// signal and trigger
obja
.
elForm
.
dispatchEvent
(
new
CustomEvent
(
'change'
))
cC
.
uauth
.
showEmailGUIEffects
(
obja
,
guiMsg
)
obja
.
lastEmailValue
=
emailValue
}
)
if
(
obja
.
type
==
'doorsRegister'
)
{
obja
.
emailStatus
=
true
obja
.
elForm
.
dispatchEvent
(
new
CustomEvent
(
'change'
))
cC
.
uauth
.
showEmailGUIEffects
(
obja
,
doorsMsg
)
obja
.
lastEmailValue
=
emailValue
}
// full register
else
{
// let's see if it's also available on comexdb side
cC
.
uauth
.
callUserApi
(
"exists"
,
emailValue
,
function
(
boolExists
)
{
obja
.
emailStatus
=
!
boolExists
var
guiMsg
=
boolExists
?
'login already taken in communityexplorer'
:
'login available'
// signal and trigger
obja
.
elForm
.
dispatchEvent
(
new
CustomEvent
(
'change'
))
cC
.
uauth
.
showEmailGUIEffects
(
obja
,
guiMsg
)
obja
.
lastEmailValue
=
emailValue
}
)
}
}
// not available on doors side
// ---------------------------
else
if
(
doorsMsg
==
"LoginAlreadyExists"
)
else
if
(
doorsMsg
==
"LoginAlreadyExists"
)
{
obja
.
emailStatus
=
false
// signal and trigger
obja
.
elForm
.
dispatchEvent
(
new
CustomEvent
(
'change'
))
...
...
@@ -301,6 +315,7 @@ cmxClt = (function(cC) {
else
{
console
.
error
(
"Error with doors connection"
)
}
}
}
)
}
...
...
@@ -314,6 +329,7 @@ cmxClt = (function(cC) {
// TODO A add the status == "neutral" case
// TODO B add a status == "ERROR" case
cC
.
uauth
.
showEmailGUIEffects
=
function
(
formObj
,
ajaxMsg
)
{
// effects on dials
if
(
formObj
.
emailStatus
)
{
// icon
...
...
templates/claim_profile.html
View file @
96aebc1b
...
...
@@ -23,7 +23,7 @@
<!-- <h2 class="oldstyle">Your Profile Info</h2> -->
<p
class=
"mini-hero"
>
<span
class=
"bigger"
>
Welcome to your
archived profile
page,
Welcome to your
<b>
archived profile
</b>
page,
<strong>
{{ return_user.info.hon_title or '' }}
{{ return_user.info.last_name }}
...
...
@@ -35,7 +35,7 @@
<!-- overview -->
<h2
class=
"cat"
>
You legacy data
You
r
legacy data
</h2>
<p
class=
"mini-hero"
>
In these 2 panels, you will find your data from the
<strong>
previous version of Community Explorer
</strong>
.
...
...
@@ -160,7 +160,7 @@
<input
readonly
id=
"country"
name=
"country"
maxlength=
"60"
type=
"text"
class=
"form-control autocomp"
placeholder=
"pays"
onblur=
"
if(this.value=='France'){teamCityDivStyle.display = 'block'} else {teamCityDivStyle.display='none'}
"
onblur=
"
cmxClt.makeBold(this)"
onfocus=
"cmxClt.makeNormal(this)
"
value=
"{{ return_user.info.country }}"
>
</div>
{% endif %}
...
...
@@ -244,7 +244,7 @@
<label
for=
"org_type"
class=
"smlabel input-group-addon"
>
Institution Type
</label>
<select
id=
"org_type"
name=
"org_type"
class=
"custom-select form-control"
onchange=
"if(
this.value=='other'){otherInstDivStyle.display = 'block'} else {otherInstDivStyle.display='none'
}"
>
onchange=
"if(
!uinfo.org_type){console.log('hello no org_type')
}"
>
<option
selected
disabled
value=
""
>
Please select
</option>
<option
value=
"university"
>
University
</option>
<option
value=
"public R&D org"
>
Public sector R
&
D organization
</option>
...
...
@@ -252,7 +252,7 @@
<option
value=
"private org"
>
Private sector organization
</option>
<option
value=
"none"
>
None at the moment
</option>
<option
value=
"other"
onclick=
"otherInstDiv
S
tyle.display = 'block'"
onclick=
"otherInstDiv
.s
tyle.display = 'block'"
>
Other
</option>
</select>
...
...
@@ -515,6 +515,12 @@
<form
id=
"comex_createlogin_form"
enctype=
"multipart/form-data"
method=
"post"
onsubmit=
"console.info('createlogin submitted')"
>
<!-- hidden input for main user id -->
<input
id=
"return_user_luid"
name=
"return_user_luid"
type=
"text"
hidden
value=
"{{ return_user.uid | safe }}"
>
</input>
<div
class=
"question"
>
<!-- POSS login within modal like comex_test_modal -->
<p
class=
"legend"
>
Your email will also be your login for the ISC services.
</p>
...
...
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