Commit 7d7e487a authored by Christophe Maudoux's avatar Christophe Maudoux 🐛

Fix warning msg when registered TOTP display is disabled

parent 7cc56a94
......@@ -55,14 +55,14 @@ getKey = (reset) ->
setMsg 'yourTotpKey', 'success'
token = data.token
verify = ->
register = ->
val = $('#code').val()
unless val
setMsg 'fillTheForm', 'warning'
else
$.ajax
type: "POST",
url: "#{portal}/2fregisters/totp/verify"
url: "#{portal}/2fregisters/totp/register"
dataType: 'json'
data:
token: token
......@@ -82,5 +82,5 @@ $(document).ready ->
getKey(0)
$('#changekey').on 'click', () ->
getKey(1)
$('#verify').on 'click', () ->
verify()
$('#register').on 'click', () ->
register()
......@@ -5,7 +5,7 @@ LemonLDAP::NG TOTP registration script
*/
(function() {
var displayError, getKey, setMsg, token, verify;
var displayError, getKey, register, setMsg, token;
setMsg = function(msg, level) {
$('#msg').html(window.translate(msg));
......@@ -71,7 +71,7 @@ LemonLDAP::NG TOTP registration script
});
};
verify = function() {
register = function() {
var val;
val = $('#code').val();
if (!val) {
......@@ -79,7 +79,7 @@ LemonLDAP::NG TOTP registration script
} else {
return $.ajax({
type: "POST",
url: portal + "/2fregisters/totp/verify",
url: portal + "/2fregisters/totp/register",
dataType: 'json',
data: {
token: token,
......@@ -107,8 +107,8 @@ LemonLDAP::NG TOTP registration script
$('#changekey').on('click', function() {
return getKey(1);
});
return $('#verify').on('click', function() {
return verify();
return $('#register').on('click', function() {
return register();
});
});
......
(function(){var a,b,d,c,e;d=function(f,g){$("#msg").html(window.translate(f));$("#color").removeClass("message-positive message-warning message-danger alert-success alert-warning alert-danger");$("#color").addClass("message-"+g);if(g==="positive"){g="success"}return $("#color").addClass("alert-"+g)};a=function(g,f,i){var h;console.log("Error",i);h=JSON.parse(g.responseText);if(h&&h.error){h=h.error.replace(/.* /,"");console.log("Returned error",h);return d(h,"warning")}};c="";b=function(f){d("yourTotpKey","warning");return $.ajax({type:"POST",url:portal+"/2fregisters/totp/getkey",dataType:"json",data:{newkey:f},error:a,success:function(i){var g,h;if(i.error){return d(i.error,"warning")}if(!(i.portal&&i.user&&i.secret)){return d("PE24","danger")}h="otpauth://totp/"+(escape(i.portal))+":"+(escape(i.user))+"?secret="+i.secret+"&issuer="+(escape(i.portal));if(i.digits!==6){h+="&digits="+i.digits}if(i.interval!==30){h+="&period="+i.interval}g=new QRious({element:document.getElementById("qr"),value:h,size:150});$("#serialized").text(h);if(i.newkey){d("yourNewTotpKey","warning")}else{d("yourTotpKey","success")}return c=i.token}})};e=function(){var f;f=$("#code").val();if(!f){return d("fillTheForm","warning")}else{return $.ajax({type:"POST",url:portal+"/2fregisters/totp/verify",dataType:"json",data:{token:c,code:f,TOTPName:$("#TOTPName").val()},error:a,success:function(g){if(g.error){if(g.error.match(/badCode/)){return d("badCode","warning")}else{return d(g.error,"danger")}}else{return d("yourKeyIsRegistered","success")}}})}};$(document).ready(function(){b(0);$("#changekey").on("click",function(){return b(1)});return $("#verify").on("click",function(){return e()})})}).call(this);
\ No newline at end of file
(function(){var a,b,d,e,c;e=function(f,g){$("#msg").html(window.translate(f));$("#color").removeClass("message-positive message-warning message-danger alert-success alert-warning alert-danger");$("#color").addClass("message-"+g);if(g==="positive"){g="success"}return $("#color").addClass("alert-"+g)};a=function(g,f,i){var h;console.log("Error",i);h=JSON.parse(g.responseText);if(h&&h.error){h=h.error.replace(/.* /,"");console.log("Returned error",h);return e(h,"warning")}};c="";b=function(f){e("yourTotpKey","warning");return $.ajax({type:"POST",url:portal+"/2fregisters/totp/getkey",dataType:"json",data:{newkey:f},error:a,success:function(i){var g,h;if(i.error){return e(i.error,"warning")}if(!(i.portal&&i.user&&i.secret)){return e("PE24","danger")}h="otpauth://totp/"+(escape(i.portal))+":"+(escape(i.user))+"?secret="+i.secret+"&issuer="+(escape(i.portal));if(i.digits!==6){h+="&digits="+i.digits}if(i.interval!==30){h+="&period="+i.interval}g=new QRious({element:document.getElementById("qr"),value:h,size:150});$("#serialized").text(h);if(i.newkey){e("yourNewTotpKey","warning")}else{e("yourTotpKey","success")}return c=i.token}})};d=function(){var f;f=$("#code").val();if(!f){return e("fillTheForm","warning")}else{return $.ajax({type:"POST",url:portal+"/2fregisters/totp/register",dataType:"json",data:{token:c,code:f,TOTPName:$("#TOTPName").val()},error:a,success:function(g){if(g.error){if(g.error.match(/badCode/)){return e("badCode","warning")}else{return e(g.error,"danger")}}else{return e("yourKeyIsRegistered","success")}}})}};$(document).ready(function(){b(0);$("#changekey").on("click",function(){return b(1)});return $("#register").on("click",function(){return d()})})}).call(this);
\ No newline at end of file
......@@ -159,6 +159,7 @@
"noHistory":"This is your first connection, welcome!",
"notAuthorized":"You're not authorized too do this",
"notFound": "Not found: you try to access to an unavailable page",
"noTOTPFound":"No TOTP found",
"noU2FKeyFound": "No U2F key found",
"oidcConsent":"The application %s would like to know:",
"oidcConsents": "OIDC consents",
......
......@@ -159,6 +159,7 @@
"noHistory":"This is your first connection, welcome!",
"notAuthorized":"You're not authorized too do this",
"notFound": "Not found: you try to access to an unavailable page",
"noTOTPFound":"No TOTP found",
"noU2FKeyFound": "No U2F key found",
"oidcConsent":"The application %s would like to know:",
"oidcConsents": "OIDC consents",
......
......@@ -159,6 +159,7 @@
"noHistory":"This is your first connection, welcome!",
"notAuthorized":"You're not authorized too do this",
"notFound": "Not found: you try to access to an unavailable page",
"noTOTPFound":"No TOTP found",
"noU2FKeyFound": "No U2F key found",
"oidcConsent":"The application %s would like to know:",
"oidcConsents": "OIDC consents",
......
......@@ -159,6 +159,7 @@
"noHistory":"Ceci est votre première connexion, bienvenue !",
"notAuthorized":"Vous n'êtes pas autorisé à faire cette requête",
"notFound": "Non trouvé: vous tentez d'accéder à une page non disponible",
"noTOTPFound":"Aucun secret TOTP trouvé",
"noU2FKeyFound": "Aucune clef U2F trouvée",
"oidcConsent":"L'application %s voudrait connaître :",
"oidcConsents": "Accords OIDC",
......
......@@ -159,6 +159,7 @@
"noHistory":"Questa è la tua prima connessione, benvenuto!",
"notAuthorized":"You're not authorized too do this",
"notFound": "Non trovato: si tenta di accedere ad una pagina non disponibile",
"noTOTPFound":"No TOTP found",
"noU2FKeyFound": "No U2F key found",
"oidcConsent":"L'applicazione %s vorrebbe sapere:",
"oidcConsents": "OIDC consents",
......
......@@ -159,6 +159,7 @@
"noHistory":"This is your first connection, welcome!",
"notAuthorized":"You're not authorized too do this",
"notFound": "Not found: you try to access to an unavailable page",
"noTOTPFound":"No TOTP found",
"noU2FKeyFound": "No U2F key found",
"oidcConsent":"The application %s would like to know:",
"oidcConsents": "OIDC consents",
......
......@@ -159,6 +159,7 @@
"noHistory":"This is your first connection, welcome!",
"notAuthorized":"You're not authorized too do this",
"notFound": "Not found: you try to access to an unavailable page",
"noTOTPFound":"No TOTP found",
"noU2FKeyFound": "No U2F key found",
"oidcConsent":"The application %s would like to know:",
"oidcConsents": "OIDC consents",
......
......@@ -159,6 +159,7 @@
"noHistory":"This is your first connection, welcome!",
"notAuthorized":"You're not authorized too do this",
"notFound": "Not found: you try to access to an unavailable page",
"noTOTPFound":"No TOTP found",
"noU2FKeyFound": "No U2F key found",
"oidcConsent":"The application %s would like to know:",
"oidcConsents": "OIDC consents",
......
......@@ -159,6 +159,7 @@
"noHistory":"Đây là kết nối đầu tiên của bạn, chào mừng!",
"notAuthorized":"You're not authorized too do this",
"notFound": "Không tìm thấy: bạn cố gắng truy cập vào một trang không có sẵn",
"noTOTPFound":"No TOTP found",
"noU2FKeyFound": "No U2F key found",
"oidcConsent":"Ứng dụng % s muốn biết:",
"oidcConsents": "OIDC consents",
......
......@@ -23,9 +23,9 @@
<span trspan="changeKey">Change key</span>
</span>
&nbsp;&nbsp;
<span id="verify" class="btn btn-success" role="button">
<span id="register" class="btn btn-success" role="button">
<span class="glyphicon glyphicon-check"></span>&nbsp;
<span trspan="verify">Verify</span>
<span trspan="register">Register</span>
</span>
</div>
</div>
......
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