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
ffcc487f
Commit
ffcc487f
authored
Nov 28, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
email validation now also checks if user exists in doors
parent
497c84d8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
96 deletions
+115
-96
Dockerfile
setup/dockers/minidoors/Dockerfile
+1
-1
regcomex_config.ini
setup/regcomex_config.ini
+2
-2
comex_reg.css
static/css/comex_reg.css
+0
-11
comex_reg_form_controllers.js
static/js/comex_reg_form_controllers.js
+95
-68
base_form.html
templates/base_form.html
+17
-14
No files found.
setup/dockers/minidoors/Dockerfile
View file @
ffcc487f
...
@@ -8,7 +8,7 @@ FROM java:8
...
@@ -8,7 +8,7 @@ FROM java:8
# cf. doors/application/build.sbt for correct version
# cf. doors/application/build.sbt for correct version
ENV
SCALA_VERSION 2.11.8
ENV
SCALA_VERSION 2.11.8
ENV
SBT_VERSION 0.13.12
ENV
SBT_VERSION 0.13.12
ENV
DOORS_COMMIT
ef7c5e0
ENV
DOORS_COMMIT
fca0f79
# Install Scala
# Install Scala
## Piping curl directly in tar
## Piping curl directly in tar
...
...
setup/regcomex_config.ini
View file @
ffcc487f
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
# ==========================
# ==========================
export
HOST
=
localhost
export
HOST
=
localhost
export
SQL_HOST
=
localhost
export
SQL_HOST
=
172.18.0.2
export
DOORS_HOST
=
localhost
export
DOORS_HOST
=
localhost
export
DOORS_PORT
=
327
89
export
DOORS_PORT
=
89
89
export
DEBUG_FLAG
=
false
export
DEBUG_FLAG
=
false
static/css/comex_reg.css
View file @
ffcc487f
...
@@ -62,17 +62,6 @@
...
@@ -62,17 +62,6 @@
/*color: #554 ;*/
/*color: #554 ;*/
}
}
/* the doors status message (a special legend) */
#doors_ret_message
{
font-size
:
150%
;
text-align
:
center
;
color
:
#554
;
display
:
none
;
/*padding: .5em 0 .5em .5em ;*/
padding
:
0
;
}
/* the question's additional legend or caption */
/* the question's additional legend or caption */
.legend
{
.legend
{
font-family
:
Cambria
,
serif
;
font-family
:
Cambria
,
serif
;
...
...
static/js/comex_reg_form_controllers.js
View file @
ffcc487f
...
@@ -84,6 +84,8 @@ theForm.onblur = beTestedAsYouGo
...
@@ -84,6 +84,8 @@ theForm.onblur = beTestedAsYouGo
// done when anything in the form changes
// done when anything in the form changes
function
beTestedAsYouGo
()
{
function
beTestedAsYouGo
()
{
console
.
log
(
"beTestedAsYouGo Go"
)
basicEmailValidate
()
basicEmailValidate
()
captchaStatus
=
(
captcha
.
value
.
length
==
realCaptchaLength
)
captchaStatus
=
(
captcha
.
value
.
length
==
realCaptchaLength
)
...
@@ -101,63 +103,87 @@ function beTestedAsYouGo() {
...
@@ -101,63 +103,87 @@ function beTestedAsYouGo() {
}
}
// NB
if login ok then user exists then not available
// NB
using new route in doors api/userExists
//
=> TODO a route for doors/api/exists
//
case true => Ok("""{"status":"login exists"}""")
//
=> resulting bool instead of (resp[0] != null
)
//
case false => Ok("""{"status":"login available"}"""
)
function
testDoorsUserExists
()
{
function
testDoorsUserExists
(
emailValue
)
{
// /!\ async
// /!\ async
callDoors
(
callDoors
(
[
email
.
value
,
pass1
.
value
,
initialsInput
.
value
],
"userExists"
,
[
emailValue
],
function
(
doorsResp
)
{
function
(
doorsResp
)
{
var
doorsUid
=
doorsResp
[
0
]
var
doorsUid
=
doorsResp
[
0
]
var
doorsMsg
=
doorsResp
[
1
]
var
doorsMsg
=
doorsResp
[
1
]
var
available
=
(
doorsUid
==
null
)
var
available
=
(
doorsMsg
==
"login available"
)
displayDoorsStatusInLoginBox
(
available
)
displayDoorsStatusInLoginBox
(
available
,
emailValue
)
},
}
"user"
)
)
}
}
// doors register then submit
function
registerDoorsAndSubmit
(
e
){
function
registerDoors
()
{
e
.
preventDefault
()
// ? not necessary if button type is set and != "submit"
submitButton
.
disabled
=
true
mainMessage
.
style
.
display
=
'block'
mainMessage
.
innerHTML
=
"Registering with ISCPIF Doors..."
// objectify the form
wholeFormData
=
new
FormData
(
theForm
);
// KNOCKING ON THE DOORS -------------------------------------
// /!\ async
// /!\ async
callDoors
(
callDoors
(
[
email
.
value
,
pass1
.
value
,
initialsInput
.
value
],
"register"
,
[
// these values from the form have been checked by beTestedAsYouGo
wholeFormData
.
get
(
"email"
),
wholeFormData
.
get
(
"password"
),
wholeFormData
.
get
(
"initials"
)
],
// VALIDATING + send to DB -------------------
function
(
doorsResp
)
{
function
(
doorsResp
)
{
var
doorsUid
=
doorsResp
[
0
]
validateSubmit
(
wholeFormData
,
doorsResp
)
var
doorsMsg
=
doorsResp
[
1
]
}
var
available
=
(
doorsUid
==
null
)
displayDoorsStatusInLoginBox
(
available
)
},
"register"
)
)
}
}
function
displayDoorsStatusInLoginBox
(
available
)
{
var
lastEmailValueCheckedDisplayed
=
null
var
doorsIcon
=
document
.
getElementById
(
'doors_ret_icon'
)
function
displayDoorsStatusInLoginBox
(
available
,
emailValue
)
{
if
(
available
)
{
if
(
available
)
{
doorsMessage
.
innerHTML
=
"This ID + password is available !"
doorsMessage
.
title
=
"This email ID is available !"
doorsMessage
.
style
.
color
=
colorGreen
doorsIcon
.
classList
.
remove
(
'glyphicon-remove'
)
doorsIcon
.
classList
.
remove
(
'glyphicon-question-sign'
)
doorsIcon
.
classList
.
add
(
'glyphicon-ok'
)
doorsIcon
.
style
.
color
=
colorGreen
}
}
else
{
else
{
doorsMessage
.
innerHTML
=
"Sorry this ID + password is already taken"
doorsMessage
.
title
=
"Sorry this email ID is already taken"
doorsMessage
.
style
.
color
=
colorRed
doorsIcon
.
classList
.
remove
(
'glyphicon-ok'
)
doorsIcon
.
classList
.
remove
(
'glyphicon-question-sign'
)
doorsIcon
.
classList
.
add
(
'glyphicon-remove'
)
doorsIcon
.
style
.
color
=
colorRed
}
}
doorsMessage
.
style
.
display
=
'block'
// to debounce further actions in basicEmailValidate
// return to neutral is also in basicEmailValidate
lastEmailValueCheckedDisplayed
=
emailValue
}
}
/* --------------- doors ajax cors function ----------------
/* --------------- doors ajax cors function ----------------
* @args:
* @args:
* data: 3-uple with mail, pass, name
* apiAction: 'register' or 'user' or 'userExists' => route to doors api
* if unknown type, default action is login via doors/api/user
*
*
* data: 3-uple with mail, pass, name
*
*
* callback: function that will be called after success AND after error
* callback: function that will be called after success AND after error
* with the return couple
* with the return couple
*
*
* apiAction: 'register' or 'user' => route to doors api
* [optional] default action is login via doors/api/user route
*
* returns couple (id, message)
* returns couple (id, message)
* ----------------------------
* ----------------------------
* ajax success <=> doorsId should be != null except if unknown error
* ajax success <=> doorsId should be != null except if unknown error
...
@@ -178,7 +204,7 @@ function displayDoorsStatusInLoginBox (available) {
...
@@ -178,7 +204,7 @@ function displayDoorsStatusInLoginBox (available) {
* }
* }
* }
* }
*/
*/
function
callDoors
(
data
,
callback
,
apiAction
)
{
function
callDoors
(
apiAction
,
data
,
callback
)
{
// console.warn("=====> CORS <=====")
// console.warn("=====> CORS <=====")
// console.log("data",data)
// console.log("data",data)
...
@@ -193,22 +219,27 @@ function callDoors(data, callback, apiAction) {
...
@@ -193,22 +219,27 @@ function callDoors(data, callback, apiAction) {
var
nameStr
=
data
[
2
]
var
nameStr
=
data
[
2
]
// test params and set defaults
// test params and set defaults
if
(
typeof
apiAction
==
'undefined'
||
apiAction
!=
'register'
)
{
if
(
typeof
apiAction
==
'undefined'
// currently forces login action unless we got 'register'
||
(
apiAction
!=
'register'
&&
apiAction
!=
'userExists'
))
{
// currently forces login action unless we got 'register' or userExists
apiAction
=
'user'
apiAction
=
'user'
console
.
warn
(
'DBG: forcing user route'
)
}
}
if
(
typeof
callback
!=
'function'
)
{
if
(
typeof
callback
!=
'function'
)
{
callback
=
function
(
retval
)
{
return
retval
}
callback
=
function
(
retval
)
{
return
retval
}
}
}
var
ok
=
(
typeof
mailStr
!=
'undefined'
console
.
log
(
"mailStr"
,
mailStr
)
&&
typeof
mailStr
!=
'undefined'
var
ok
=
((
apiAction
==
'userExists'
&&
typeof
mailStr
!=
'undefined'
&&
mailStr
)
&&
typeof
nameStr
!=
'undefined'
||
(
typeof
mailStr
!=
'undefined'
&&
mailStr
&&
passStr
)
// assumes mail and pass will nvr be == 0
&&
typeof
mailStr
!=
'undefined'
&&
typeof
nameStr
!=
'undefined'
&&
mailStr
&&
passStr
))
// assumes mail and pass will nvr be == 0
if
(
!
ok
)
{
if
(
!
ok
)
{
doorsMsg
=
"Invalid parameters in input data (arg #2)"
doorsMsg
=
"Invalid parameters in input data (arg #1)"
console
.
warn
(
'DEBUG callDoors() internal validation failed before ajax'
)
}
}
else
{
else
{
$
.
ajax
({
$
.
ajax
({
...
@@ -223,15 +254,20 @@ function callDoors(data, callback, apiAction) {
...
@@ -223,15 +254,20 @@ function callDoors(data, callback, apiAction) {
type
:
'POST'
,
type
:
'POST'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
if
(
typeof
data
!=
'undefined'
if
(
typeof
data
!=
'undefined'
&&
apiAction
==
'userExists'
)
{
// userExists success case: it's all in the message :)
doorsUid
=
null
doorsMsg
=
data
.
status
}
else
if
(
typeof
data
!=
'undefined'
&&
typeof
data
.
userInfo
!=
undefined
&&
typeof
data
.
userInfo
!=
undefined
&&
typeof
data
.
userInfo
.
id
!=
undefined
&&
typeof
data
.
userInfo
.
id
!=
undefined
&&
typeof
data
.
userInfo
.
id
.
id
!=
undefined
&&
typeof
data
.
userInfo
.
id
.
id
!=
undefined
&&
typeof
data
.
status
==
'string'
)
{
&&
typeof
data
.
status
==
'string'
)
{
// main success case
// main success case
: get the id
doorsUid
=
data
.
userInfo
.
id
.
id
doorsUid
=
data
.
userInfo
.
id
.
id
doorsMsg
=
data
.
status
doorsMsg
=
data
.
status
}
}
else
{
else
{
doorsMsg
=
"Unknown response for doors apiAction ("
+
apiAction
+
"):"
doorsMsg
=
"Unknown response for doors apiAction ("
+
apiAction
+
"):"
doorsMsg
+=
'"'
+
JSON
.
stringify
(
data
).
substring
(
0
,
10
)
+
'..."'
doorsMsg
+=
'"'
+
JSON
.
stringify
(
data
).
substring
(
0
,
10
)
+
'..."'
...
@@ -286,35 +322,6 @@ function makeRandomString(nChars) {
...
@@ -286,35 +322,6 @@ function makeRandomString(nChars) {
return
rando
return
rando
}
}
function
registerDoorsAndSubmit
(
e
){
e
.
preventDefault
()
// ? not necessary if button type is set and != "submit"
submitButton
.
disabled
=
true
mainMessage
.
style
.
display
=
'block'
mainMessage
.
innerHTML
=
"Registering with ISCPIF Doors..."
// objectify the form
wholeFormData
=
new
FormData
(
theForm
);
// KNOCKING ON THE DOORS -------------------------------------
// /!\ async
callDoors
(
[
// these values from the form have been checked by beTestedAsYouGo
wholeFormData
.
get
(
"email"
),
wholeFormData
.
get
(
"password"
),
wholeFormData
.
get
(
"initials"
)
],
// VALIDATING + send to DB -------------------
function
(
doorsResp
)
{
validateSubmit
(
wholeFormData
,
doorsResp
)
},
"register"
)
}
// doValidate() : actions to do after doors registration and before send
// doValidate() : actions to do after doors registration and before send
//
//
// => validate the columns
// => validate the columns
...
@@ -573,7 +580,27 @@ nameInputs.forEach ( function(nameInput) {
...
@@ -573,7 +580,27 @@ nameInputs.forEach ( function(nameInput) {
// very basic email validation TODO: better extension and allowed chars set :)
// very basic email validation TODO: better extension and allowed chars set :)
// (used in tests "as we go")
// (used in tests "as we go")
function
basicEmailValidate
()
{
function
basicEmailValidate
()
{
emailStatus
=
/^
[
-A-z0-9_=.+
]
+@
[
-A-z0-9_=.+
]
+
\.[
-A-z0-9_=.+
]{1,4}
$/
.
test
(
email
.
value
)
var
newValue
=
email
.
value
// tests if email is well-formed
emailStatus
=
/^
[
-A-z0-9_=.+
]
+@
[
-A-z0-9_=.+
]
+
\.[
-A-z0-9_=.+
]{1,4}
$/
.
test
(
newValue
)
console
.
log
(
"basicEmailValidate: emailStatus"
,
emailStatus
)
if
(
!
emailStatus
)
{
// restore original lack of message
doorsMessage
.
title
=
'The email will be checked in our DB after you type and leave the box.'
doorsIcon
.
classList
.
remove
(
'glyphicon-remove'
)
doorsIcon
.
classList
.
remove
(
'glyphicon-ok'
)
doorsIcon
.
classList
.
add
(
'glyphicon-question-sign'
)
doorsIcon
.
style
.
color
=
colorGrey
}
else
if
(
emailStatus
&&
(
newValue
!=
lastEmailValueCheckedDisplayed
))
{
// additional ajax to check login availability
// doesn't change the boolean but displays a message
testDoorsUserExists
(
newValue
)
}
}
}
// pass 1 and pass 2 ~~~> do they match?
// pass 1 and pass 2 ~~~> do they match?
...
...
templates/base_form.html
View file @
ffcc487f
...
@@ -150,10 +150,21 @@
...
@@ -150,10 +150,21 @@
<div
class=
"question"
>
<div
class=
"question"
>
<p
class=
"legend"
>
Your email will also be your login for the ISC services.
</p>
<p
class=
"legend"
>
Your email will also be your login for the ISC services.
</p>
<div
class=
"input-group"
>
<div
class=
"input-group"
>
<!-- TODO email validation onblur/onchange if value -->
<!-- email validation onblur/onchange
is done by basicEmailValidate
and testDoorsUserExists
in comex_reg_form_controllers.js -->
<label
for=
"email"
class=
"smlabel input-group-addon"
>
* Email
</label>
<label
for=
"email"
class=
"smlabel input-group-addon"
>
* Email
</label>
<input
id=
"email"
name=
"email"
maxlength=
"255"
<input
id=
"email"
name=
"email"
maxlength=
"255"
type=
"text"
class=
"form-control"
placeholder=
"email"
>
type=
"text"
class=
"form-control"
placeholder=
"email"
>
<!-- doors return value icon -->
<div
id=
"doors_ret_message"
class=
"input-group-addon"
title=
"The email will be checked in our DB after you type and leave the box."
>
<span
id=
"doors_ret_icon"
class=
"glyphicon glyphicon-question-sign grey"
></span>
</div>
</div>
</div>
</div>
</div>
...
@@ -175,17 +186,6 @@
...
@@ -175,17 +186,6 @@
<p
id=
"password_message"
class=
"legend red"
style=
"font-weight:bold"
></p>
<p
id=
"password_message"
class=
"legend red"
style=
"font-weight:bold"
></p>
</div>
</div>
<button
type=
button
class=
"btn btn-sm btn-default"
style=
"float:right"
id=
"knock_on_doors"
onclick=
"testDoorsUserExists()"
>
Check login availability at ISCPIF Doors
</button>
<!-- doors return value message -->
<p
id=
"doors_ret_message"
class=
"legend"
></p>
<!-- JOB & INTERESTS -->
<!-- JOB & INTERESTS -->
<h3
class=
"formcat"
>
About your job and research
</h3>
<h3
class=
"formcat"
>
About your job and research
</h3>
...
@@ -399,12 +399,15 @@
...
@@ -399,12 +399,15 @@
<!-- FOR DEBUG: test go-between with Doors -->
<!-- FOR DEBUG: test go-between with Doors -->
<!-- <p>
<!-- <p>
<button type=button onclick='callDoors(
[email.value, pass1.value, initialsInput.value], console.warn, "user"
)'>
<button type=button onclick='callDoors(
"user", [email.value, pass1.value, initialsInput.value], console.warn
)'>
test doors login
test doors login
</button>
</button>
<button type=button onclick='callDoors(
[email.value, pass1.value, initialsInput.value], "register"
, console.warn)'>
<button type=button onclick='callDoors(
"register", [email.value, pass1.value, initialsInput.value]
, console.warn)'>
test doors register
test doors register
</button>
</button>
<button type=button onclick='callDoors("userExists", [email.value, null, null], console.warn)'>
test doors userExists
</button>
</p> -->
</p> -->
</div>
</div>
...
...
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