Commit 5214a76b authored by Eric Seigne's avatar Eric Seigne
Browse files

gestion de l'authentification qrcode + mémorisation du compte

parent bd475ae2
......@@ -204,7 +204,8 @@ function loginButtonPressed(accountID=null){let remember=0;let lemail=document.g
localStoreData("email",lemail);localStoreData("rememberMe",remember);myDebug("loginButtonPressed pour "+lemail);showWait();globalDoliScanDomain=lemail.replace(/.*@/,"doliscan.");myDebug('On cherche '+globalDoliScanDomain);var testURL="https://"+globalDoliScanDomain+"/api/hello";myDebug("-> tentative de découverte d'un serveur doliscan sur "+testURL);showWait();if(ajaxRequestDiscover)
ajaxRequestDiscover.abort();var ajaxRequestDiscover=$.ajax({url:testURL,timeout:5000,type:"POST",data:{email:lemail,},dataType:"json",success:function(data,textStatus,request){hideWait();myDebug('success ! -> '+data);myDebug(request);localStoreData("email",lemail);localStoreData("api_server","https://"+globalDoliScanDomain);localStoreData("name_server",globalDoliScanDomain);myDebug("Request finished (api/hello)");loginJson();},error:function(request,textStatus,error){hideWait();if(textStatus==="timeout"){myDebug("Request finished (error signal) : "+textStatus);}
myDebug("Request finished (error signal) : "+textStatus);myDebug(request);myDebug(error);myDebug('error, fallback to doliscan.fr !');localStoreData("api_server","https://doliscan.fr");localStoreData("name_server","doliscan.fr");loginJson();}});}
function loginJson(){myDebug("Tentative de connexion JSON ...");let lemail=document.getElementById('email').value;let lpassword=document.getElementById('password').value;let carousel=document.getElementById('carousel');showWait();var loginURI=localGetData("api_server")+"/api/login";myDebug(' loginJson : tentative de login via ajax request vers le serveur '+loginURI+' pour '+lemail+' **'+lpassword+"**");if(ajaxRequestLoginJSON)
function loginJson(){myDebug("Tentative de connexion JSON ...");let lemail=document.getElementById('email').value;let lpassword=document.getElementById('password').value;let carousel=document.getElementById('carousel');showWait();var loginURI=localGetData("api_server")+"/api/login";myDebug(' loginJson : tentative de login via ajax request vers le serveur '+loginURI+' pour '+lemail+' **'+lpassword+"**");let remember=0;if(document.getElementById('rememberMe').checked){remember=1;}
localStoreData("rememberMe",remember);if(ajaxRequestLoginJSON)
ajaxRequestLoginJSON.abort();var ajaxRequestLoginJSON=$.ajax({url:loginURI,timeout:5000,type:"POST",data:{email:lemail,password:lpassword,},success:function(result,textStatus,request){hideWait();myDebug("loginJson success ");globalNetworkResponse=Date.now();if(typeof result!='undefined'){if(typeof result.data!='undefined'&&typeof result.data.api_token!='undefined'){if(result.data.api_version==globalCompatibleWithAPIVersion){updateLocalUserFromServer(result,updateLocalUserFromServerSuccess);}
else{if(typeof result.data.api_version_message!='undefined'){$("#messagePopupMessage").replaceWith(result.data.api_version_message);$("#messagePopup").show();}
$("#erreurLogin").show();myDebug("carouselLogin call 5");carouselLogin();}}
......
......@@ -252,6 +252,11 @@ function loginJson() {
showWait();
var loginURI = localGetData("api_server") + "/api/login";
myDebug(' loginJson : tentative de login via ajax request vers le serveur ' + loginURI + ' pour ' + lemail + ' **' + lpassword + "**");
let remember = 0;
if (document.getElementById('rememberMe').checked) {
remember = 1;
}
localStoreData("rememberMe", remember);
//au cas ou
if (ajaxRequestLoginJSON)
......
......@@ -157,7 +157,7 @@
</ons-card>
</ons-col>
</ons-row>
</form>
</form>
</div>
</ons-carousel-item>
</ons-carousel>
......@@ -196,6 +196,13 @@
localStoreData("api_token", res[2]);
localStoreData("api_server", "https://" + globalDoliScanDomain);
localStoreData("name_server", globalDoliScanDomain);
let remember = 0;
if (document.getElementById('rememberMe').checked) {
remember = 1;
}
localStoreData("rememberMe", remember);
loginWithAPIToken();
},
function (error) {
......
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