diff --git a/assets/js/common/formChecker.js b/assets/js/common/formChecker.js index 01a5baea..1fdda017 100644 --- a/assets/js/common/formChecker.js +++ b/assets/js/common/formChecker.js @@ -33,7 +33,7 @@ ComunicWeb.common.formChecker = { //MailInput else if(inputType == "email"){ - inputOK = input.value.match(/^[a-zA-Z0-9_.]+@[a-zA-Z0-9-]{1,}[.][a-zA-Z]{2,3}$/); + inputOK = checkMail(input.value); } //Password input diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index b76c9e66..61c1d7d0 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -334,6 +334,14 @@ var ComunicWeb = { } }, + /** + * Mails caching component + */ + mailCaching: { + //TODO : implement + } + + }, /** diff --git a/assets/js/common/utils.js b/assets/js/common/utils.js index 9c05cf3b..fd1400fe 100644 --- a/assets/js/common/utils.js +++ b/assets/js/common/utils.js @@ -31,6 +31,16 @@ function byId(nodeName){ return document.getElementById(nodeName); } +/** + * Check a given email address + * + * @param {String} emailAddress The email address to check + * @return {Boolean} True for a valid email address / false else + */ +function checkMail(emailAddress){ + return (emailAddress.match(/^[a-zA-Z0-9_.]+@[a-zA-Z0-9-]{1,}[.][a-zA-Z]{2,5}$/) === null ? false : true); +} + /** * Create a quick language access function shorcut */ diff --git a/assets/js/components/mailCaching.js b/assets/js/components/mailCaching.js new file mode 100644 index 00000000..d50b019c --- /dev/null +++ b/assets/js/components/mailCaching.js @@ -0,0 +1,47 @@ +/** + * Mail caching controller + * + * @author Pierre HUBERT + */ + +ComunicWeb.components.mailCaching = { + + /** + * @var Mail caching variable name + */ + __mailCachingVarName: "lastLoginMail", + + /** + * Get current cached value + * + * @return {String} The current stored mail / Empty string if it doesn't exist + */ + get: function(){ + //Try to get mail value + var mail = localStorage.getItem(this.__mailCachingVarName); + + //If not any mail was defined + if(!mail) + return ""; //Empty value + + return mail; + }, + + /** + * Set a new mail value + * + * @param {String} mail The mail address + * @return {Boolean} True for a success + */ + set: function(mail){ + + //Check mail first + if(!checkMail(mail)) + return false; + + //Try to save mail + localStorage.setItem(this.__mailCachingVarName, mail); + return true; + }, + +} \ No newline at end of file diff --git a/assets/js/components/mailCachingController.js b/assets/js/components/mailCachingController.js deleted file mode 100644 index 6c52fe74..00000000 --- a/assets/js/components/mailCachingController.js +++ /dev/null @@ -1,5 +0,0 @@ -/** - * Mail caching controller - * - * @author Pierre HUBERT - */ \ No newline at end of file diff --git a/assets/js/components/menuBar/notAuthenticated.js b/assets/js/components/menuBar/notAuthenticated.js index b8a01b03..2366da51 100644 --- a/assets/js/components/menuBar/notAuthenticated.js +++ b/assets/js/components/menuBar/notAuthenticated.js @@ -23,7 +23,9 @@ ComunicWeb.components.menuBar.notAuthenticated = { loginForm.setAttribute("role", "login"); loginForm.onsubmit = function(){ - //Try to login user; in case of failure redirect + //Try to login user; in case of failure redirect to login page + + return false; } //Add email address formGroup diff --git a/assets/js/pagesList.js b/assets/js/pagesList.js index 189cabd8..f219778c 100644 --- a/assets/js/pagesList.js +++ b/assets/js/pagesList.js @@ -29,6 +29,7 @@ ComunicWeb.pagesList = { logout: { pageTitle: "Logout", methodHandler: "ComunicWeb.pages.logout.openLogoutPage", + disableMenus: true, }, /** diff --git a/corePage/config/dev.config.php b/corePage/config/dev.config.php index dbbcf309..d7ae054c 100644 --- a/corePage/config/dev.config.php +++ b/corePage/config/dev.config.php @@ -58,6 +58,7 @@ $config['JSfiles'] = array( "%PATH_ASSETS%js/common/system.js", //Components + "%PATH_ASSETS%js/components/mailCaching.js", "%PATH_ASSETS%js/components/menuBar/common.js", "%PATH_ASSETS%js/components/menuBar/notAuthenticated.js",