Commit debe2e30 authored by Romain Loth's avatar Romain Loth

fix registration form namespace issues that came up after js refactoring

parent dbb64780
...@@ -112,7 +112,7 @@ function testDoorsUserExists(emailValue) { ...@@ -112,7 +112,7 @@ function testDoorsUserExists(emailValue) {
function registerDoorsAndSubmit(){ function registerDoorsAndSubmit(){
mainMessage.innerHTML = "Registering with ISCPIF Doors..." cmxClt.uform.mainMessage.innerHTML = "Registering with ISCPIF Doors..."
// all values from the form have now been validated // all values from the form have now been validated
var emailValue = cmxClt.uauth.email.value var emailValue = cmxClt.uauth.email.value
...@@ -129,7 +129,7 @@ function registerDoorsAndSubmit(){ ...@@ -129,7 +129,7 @@ function registerDoorsAndSubmit(){
// REGISTERING ON THE DOORS ------------------------------------- // REGISTERING ON THE DOORS -------------------------------------
// /!\ async // /!\ async
callDoors( cmxClt.uauth.callDoors(
"register", "register",
[emailValue, passValue, wholenameValue], [emailValue, passValue, wholenameValue],
...@@ -152,8 +152,7 @@ function addUidThenSubmit(doorsResp) { ...@@ -152,8 +152,7 @@ function addUidThenSubmit(doorsResp) {
} }
else { else {
// fill in the answer we got // fill in the answer we got
// £TODO fix scope uauth and uform ? ccModule.uauth.uidInput.value = doorsUid
uidInput.value = doorsUid
console.info("form was validated and registered@doors: submitting now") console.info("form was validated and registered@doors: submitting now")
...@@ -187,7 +186,7 @@ function validateAndMsg() { ...@@ -187,7 +186,7 @@ function validateAndMsg() {
if (jobDate.value.length) jobDate.value = (new Date(jobDate.value)).toISOString() if (jobDate.value.length) jobDate.value = (new Date(jobDate.value)).toISOString()
// objectify the form // objectify the form
cmxClt.uform.wholeFormData = new FormData(theForm); cmxClt.uform.wholeFormData = new FormData(cmxClt.uform.theForm);
var missingFields = [] var missingFields = []
var toolongFields = [] var toolongFields = []
...@@ -246,8 +245,8 @@ function validateAndMsg() { ...@@ -246,8 +245,8 @@ function validateAndMsg() {
// RESULTS // RESULTS
if (valid) { if (valid) {
// add the captchaCheck inside the form (TODO should be automatic via realperson or uauth submodules) // adds the captchaCheck inside the form
cmxClt.uauth.captchaCheck.value = $(captcha).realperson('getHash') ccModule.uauth.collectCaptcha()
cmxClt.uform.mainMessage.innerHTML = "Form is valid... Will register and submit..." cmxClt.uform.mainMessage.innerHTML = "Form is valid... Will register and submit..."
cmxClt.uform.mainMessage.style.display = 'block' cmxClt.uform.mainMessage.style.display = 'block'
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
// cmxClt module augmentation // cmxClt module augmentation
// POSS remove ccModule.auth. namespace prefix from local scope vars
cmxClt = (function(ccModule) { cmxClt = (function(ccModule) {
// common vars to authenticating/registering in user area // common vars to authenticating/registering in user area
ccModule.uauth = {} ccModule.uauth = {}
...@@ -30,18 +31,25 @@ cmxClt = (function(ccModule) { ...@@ -30,18 +31,25 @@ cmxClt = (function(ccModule) {
// str of the form: doors_hostname:doors_port // str of the form: doors_hostname:doors_port
ccModule.uauth.doorsConnectParam = document.getElementById('doors_connect').value ccModule.uauth.doorsConnectParam = document.getElementById('doors_connect').value
// captchaHash should be appended by itself if normal submit, // captcha
// but we may need to do it ourselves (TODO test) // -------
ccModule.uauth.captcha = document.getElementById('my-captcha') ccModule.uauth.captcha = document.getElementById('my-captcha')
ccModule.uauth.captchaCheck = document.getElementById('my-captchaHash')
// param for generation & validation // param for generation & validation
ccModule.uauth.realCaptchaLength = 5 ccModule.uauth.realCaptchaLength = 5
// initialize pseudo captcha // captcha init
$('#my-captcha').realperson({length: ccModule.uauth.realCaptchaLength}); $(cmxClt.uauth.captcha).realperson({length: ccModule.uauth.realCaptchaLength})
// captchaHash should be appended by itself if normal submit,
// but otherwise we need to do it ourselves with collectCaptcha()
ccModule.uauth.captchaCheck = document.getElementById('my-captchaHash')
ccModule.uauth.collectCaptcha = function() {
ccModule.uauth.captchaCheck.value = $(cmxClt.uauth.captcha).realperson('getHash')
}
// doors-related html elements // doors-related html elements
// ---------------------------
ccModule.uauth.doorsMessage = document.getElementById('doors_ret_message') ccModule.uauth.doorsMessage = document.getElementById('doors_ret_message')
ccModule.uauth.doorsIconMessage = document.getElementById('doors_ret_icon_msg') ccModule.uauth.doorsIconMessage = document.getElementById('doors_ret_icon_msg')
ccModule.uauth.doorsIcon = document.getElementById('doors_ret_icon') ccModule.uauth.doorsIcon = document.getElementById('doors_ret_icon')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment