mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Connected menuBar login form to login page
This commit is contained in:
parent
72fe4108ba
commit
5c5a65cdff
@ -10,6 +10,11 @@ var ComunicWeb = {
|
|||||||
*/
|
*/
|
||||||
__config: ComunicConfig,
|
__config: ComunicConfig,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of available pages
|
||||||
|
*/
|
||||||
|
pagesList:{},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common functions
|
* Common functions
|
||||||
*/
|
*/
|
||||||
@ -386,6 +391,13 @@ var ComunicWeb = {
|
|||||||
* Perform user login
|
* Perform user login
|
||||||
*/
|
*/
|
||||||
loginSubmit: function(){},
|
loginSubmit: function(){},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display login error message
|
||||||
|
*
|
||||||
|
* @return {Boolean} True for a success
|
||||||
|
*/
|
||||||
|
displayLoginError: function(){},
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -399,4 +411,4 @@ var ComunicWeb = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
}
|
};
|
@ -24,6 +24,11 @@ ComunicWeb.components.menuBar.notAuthenticated = {
|
|||||||
|
|
||||||
loginForm.onsubmit = function(){
|
loginForm.onsubmit = function(){
|
||||||
//Try to login user; in case of failure redirect to login page
|
//Try to login user; in case of failure redirect to login page
|
||||||
|
//TODO : implement
|
||||||
|
//In case of error
|
||||||
|
ComunicWeb.common.page.openPage("login", {
|
||||||
|
loginFailedMessage: true,
|
||||||
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -37,6 +42,7 @@ ComunicWeb.components.menuBar.notAuthenticated = {
|
|||||||
emailInput.className = "form-control";
|
emailInput.className = "form-control";
|
||||||
emailInput.placeholder = "Email address";
|
emailInput.placeholder = "Email address";
|
||||||
emailInput.type = "email";
|
emailInput.type = "email";
|
||||||
|
emailInput.value = ComunicWeb.components.mailCaching.get();
|
||||||
|
|
||||||
//Add password formGroup
|
//Add password formGroup
|
||||||
var passwordFormGroup = createElem("div", loginForm);
|
var passwordFormGroup = createElem("div", loginForm);
|
||||||
|
@ -26,7 +26,7 @@ ComunicWeb.pages.login = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Prepare additional data
|
//Prepare additional data
|
||||||
var additionalData = {};
|
var additionalTemplateData = {};
|
||||||
|
|
||||||
//Preparing next actions
|
//Preparing next actions
|
||||||
var afterParsingTemplate = function(){
|
var afterParsingTemplate = function(){
|
||||||
@ -42,6 +42,9 @@ ComunicWeb.pages.login = {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Define email address (if possible)
|
||||||
|
byId("usermail").value = ComunicWeb.components.mailCaching.get();
|
||||||
|
|
||||||
//Get login form element
|
//Get login form element
|
||||||
var loginBody = document.getElementById("loginForm");
|
var loginBody = document.getElementById("loginForm");
|
||||||
|
|
||||||
@ -51,10 +54,17 @@ ComunicWeb.pages.login = {
|
|||||||
//Make the login action accessible
|
//Make the login action accessible
|
||||||
//loginButton.onclick = ComunicWeb.pages.login.loginSubmit;
|
//loginButton.onclick = ComunicWeb.pages.login.loginSubmit;
|
||||||
loginBody.onsubmit = ComunicWeb.pages.login.loginSubmit;
|
loginBody.onsubmit = ComunicWeb.pages.login.loginSubmit;
|
||||||
|
|
||||||
|
//Check if additionnal data were specified
|
||||||
|
if(additionnalData){
|
||||||
|
//Check if we have to display a login failed message
|
||||||
|
if(additionnalData.loginFailedMessage)
|
||||||
|
ComunicWeb.pages.login.displayLoginError();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Apply template
|
//Apply template
|
||||||
ComunicWeb.common.page.getAndShowTemplate(targetElement, additionalData, "pages/login/loginPage.tpl", afterParsingTemplate, true);
|
ComunicWeb.common.page.getAndShowTemplate(targetElement, additionalTemplateData, "pages/login/loginPage.tpl", afterParsingTemplate, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,8 +74,8 @@ ComunicWeb.pages.login = {
|
|||||||
*/
|
*/
|
||||||
loginSubmit: function(){
|
loginSubmit: function(){
|
||||||
//Get inputs
|
//Get inputs
|
||||||
var usermailInput = document.getElementById("usermail"); //Usermail
|
var usermailInput = byId("usermail"); //Usermail
|
||||||
var userpasswordInput = document.getElementById("userpassword"); //Password
|
var userpasswordInput = byId("userpassword"); //Password
|
||||||
var rememberLoginInput = document.getElementById("rememberLogin"); //Remember login
|
var rememberLoginInput = document.getElementById("rememberLogin"); //Remember login
|
||||||
|
|
||||||
//Check inputs
|
//Check inputs
|
||||||
@ -94,14 +104,14 @@ ComunicWeb.pages.login = {
|
|||||||
//First, remove overlay
|
//First, remove overlay
|
||||||
screenOverlay.remove();
|
screenOverlay.remove();
|
||||||
|
|
||||||
|
//Save email address
|
||||||
|
ComunicWeb.components.mailCaching.set(usermail);
|
||||||
|
|
||||||
//Check if login failed
|
//Check if login failed
|
||||||
if(!loginResult){
|
if(!loginResult){
|
||||||
//Create error modal
|
|
||||||
errorMessageElem = ComunicWeb.common.messages.createCalloutElem("Login failed", "Please check your usermail and password", "danger");
|
|
||||||
|
|
||||||
//Apply error modal
|
//Display error
|
||||||
document.getElementById('loginMessagesTarget').innerHTML = "";
|
ComunicWeb.pages.login.displayLoginError();
|
||||||
document.getElementById('loginMessagesTarget').appendChild(errorMessageElem);
|
|
||||||
|
|
||||||
//Return false
|
//Return false
|
||||||
return false;
|
return false;
|
||||||
@ -114,4 +124,21 @@ ComunicWeb.pages.login = {
|
|||||||
//Try to login user
|
//Try to login user
|
||||||
ComunicWeb.user.userLogin.loginUser(usermail, userpassword, permanentLogin, afterTryLogin);
|
ComunicWeb.user.userLogin.loginUser(usermail, userpassword, permanentLogin, afterTryLogin);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display login error message
|
||||||
|
*
|
||||||
|
* @return {Boolean} True for a success
|
||||||
|
*/
|
||||||
|
displayLoginError: function(){
|
||||||
|
//Create error modal
|
||||||
|
errorMessageElem = ComunicWeb.common.messages.createCalloutElem("Login failed", "Please check your usermail and password", "danger");
|
||||||
|
|
||||||
|
//Apply error modal
|
||||||
|
document.getElementById('loginMessagesTarget').innerHTML = "";
|
||||||
|
document.getElementById('loginMessagesTarget').appendChild(errorMessageElem);
|
||||||
|
|
||||||
|
//Success
|
||||||
|
return true;
|
||||||
|
},
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user