mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Handle "too many request" login errors.
This commit is contained in:
parent
ee2689ad84
commit
06b43732a9
@ -397,6 +397,8 @@ var ComunicWeb = {
|
|||||||
* Logout user
|
* Logout user
|
||||||
*/
|
*/
|
||||||
logoutUser: function(afterLogout){},
|
logoutUser: function(afterLogout){},
|
||||||
|
|
||||||
|
//TODO : implement
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -181,6 +181,7 @@ ComunicWeb.common.langs.en = {
|
|||||||
_login_page_password_placeholder: "Password",
|
_login_page_password_placeholder: "Password",
|
||||||
_login_page_submit: "Sign In",
|
_login_page_submit: "Sign In",
|
||||||
_login_page_error_head: "Login failed",
|
_login_page_error_head: "Login failed",
|
||||||
|
too_many_login_request_try_again_later: "Too many unsuccessfull login attempts. Please try again later...",
|
||||||
_login_page_error_message: "Please check your usermail and password !",
|
_login_page_error_message: "Please check your usermail and password !",
|
||||||
_login_page_bad_input: "Please check what you've typed !",
|
_login_page_bad_input: "Please check what you've typed !",
|
||||||
_login_page_create_account_lnk: "Create an account",
|
_login_page_create_account_lnk: "Create an account",
|
||||||
|
@ -180,6 +180,7 @@ ComunicWeb.common.langs.fr = {
|
|||||||
_login_page_password_placeholder: "Mot de passe",
|
_login_page_password_placeholder: "Mot de passe",
|
||||||
_login_page_submit: "Connexion",
|
_login_page_submit: "Connexion",
|
||||||
_login_page_error_head: "La connexion a échouée",
|
_login_page_error_head: "La connexion a échouée",
|
||||||
|
too_many_login_request_try_again_later: "Trop de tentatives de connexion infructueuses. Veuillez réessayer ultérieurement...",
|
||||||
_login_page_error_message: "Veuillez vérifier votre identifiant et votre mot de passe !",
|
_login_page_error_message: "Veuillez vérifier votre identifiant et votre mot de passe !",
|
||||||
_login_page_bad_input: "Veuillez vérifier votre saisie...",
|
_login_page_bad_input: "Veuillez vérifier votre saisie...",
|
||||||
_login_page_create_account_lnk: "Créer un compte",
|
_login_page_create_account_lnk: "Créer un compte",
|
||||||
|
@ -146,8 +146,16 @@ ComunicWeb.pages.login = {
|
|||||||
* @return {Boolean} True for a success
|
* @return {Boolean} True for a success
|
||||||
*/
|
*/
|
||||||
displayLoginError: function(){
|
displayLoginError: function(){
|
||||||
|
|
||||||
|
//Find the right error message
|
||||||
|
if(ComunicWeb.user.userLogin.get_last_attempt_response_code() == 429)
|
||||||
|
var code = "too_many_login_request_try_again_later";
|
||||||
|
//Default error messsage
|
||||||
|
else
|
||||||
|
var code = "_login_page_error_message";
|
||||||
|
|
||||||
//Create error modal
|
//Create error modal
|
||||||
errorMessageElem = ComunicWeb.common.messages.createCalloutElem(lang("_login_page_error_head"), lang("_login_page_error_message"), "danger");
|
errorMessageElem = ComunicWeb.common.messages.createCalloutElem(lang("_login_page_error_head"), lang(code), "danger");
|
||||||
|
|
||||||
//Apply error modal
|
//Apply error modal
|
||||||
document.getElementById('loginMessagesTarget').innerHTML = "";
|
document.getElementById('loginMessagesTarget').innerHTML = "";
|
||||||
|
@ -16,6 +16,12 @@ ComunicWeb.user.userLogin = {
|
|||||||
*/
|
*/
|
||||||
__userID: 0,
|
__userID: 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var {number} lastAttemptResponseCode Last login attempt response code
|
||||||
|
*/
|
||||||
|
_last_attempt_response_code: 0,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tell if user is logged in or not
|
* Tell if user is logged in or not
|
||||||
@ -168,6 +174,7 @@ ComunicWeb.user.userLogin = {
|
|||||||
|
|
||||||
//Perform next action if login failed
|
//Perform next action if login failed
|
||||||
if(!loginstate) {
|
if(!loginstate) {
|
||||||
|
ComunicWeb.user.userLogin._last_attempt_response_code = result.error.code;
|
||||||
afterLogin(loginstate);
|
afterLogin(loginstate);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -231,4 +238,11 @@ ComunicWeb.user.userLogin = {
|
|||||||
//Done !
|
//Done !
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get last login attempt response code
|
||||||
|
*/
|
||||||
|
get_last_attempt_response_code: function(){
|
||||||
|
return this._last_attempt_response_code;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user