Commit eefd820c authored by Christophe Maudoux's avatar Christophe Maudoux

Fix msg type

parent 26942c64
...@@ -74,8 +74,8 @@ verify = -> ...@@ -74,8 +74,8 @@ verify = ->
error: displayError error: displayError
success: (data) -> success: (data) ->
if data.error if data.error
if data.error.match /badCode/ if data.error.match /bad(Code|Name)/
setMsg 'badCode', 'warning' setMsg data.error, 'warning'
else else
setMsg data.error, 'danger' setMsg data.error, 'danger'
else else
......
...@@ -4,7 +4,7 @@ LemonLDAP::NG U2F registration script ...@@ -4,7 +4,7 @@ LemonLDAP::NG U2F registration script
setMsg = (msg, level) -> setMsg = (msg, level) ->
$('#msg').html window.translate msg $('#msg').html window.translate msg
$('#color').removeClass 'message-positive message-warning alert-success alert-warning' $('#color').removeClass 'message-positive message-warning message-danger alert-success alert-warning alert-danger'
$('#color').addClass "message-#{level}" $('#color').addClass "message-#{level}"
level = 'success' if level == 'positive' level = 'success' if level == 'positive'
$('#color').addClass "alert-#{level}" $('#color').addClass "alert-#{level}"
...@@ -52,8 +52,8 @@ register = -> ...@@ -52,8 +52,8 @@ register = ->
success: (resp) -> success: (resp) ->
if resp.error if resp.error
if resp.error.match /badName/ if resp.error.match /badName/
setMsg 'badName', 'warning' setMsg resp.error, 'warning'
else setMsg 'u2fFailed', 'warning' else setMsg 'u2fFailed', 'danger'
else if resp.result else if resp.result
setMsg 'yourKeyIsRegistered', 'positive' setMsg 'yourKeyIsRegistered', 'positive'
error: displayError error: displayError
...@@ -85,7 +85,7 @@ verify = -> ...@@ -85,7 +85,7 @@ verify = ->
dataType: 'json' dataType: 'json'
success: (resp) -> success: (resp) ->
if resp.error if resp.error
setMsg 'u2fFailed', 'warning' setMsg 'u2fFailed', 'danger'
else if resp.result else if resp.result
setMsg 'yourKeyIsVerified', 'positive' setMsg 'yourKeyIsVerified', 'positive'
error: (j, status, err) -> error: (j, status, err) ->
......
// Generated by CoffeeScript 1.9.3 // Generated by CoffeeScript 1.12.7
/* /*
LemonLDAP::NG TOTP registration script LemonLDAP::NG TOTP registration script
...@@ -93,8 +93,8 @@ LemonLDAP::NG TOTP registration script ...@@ -93,8 +93,8 @@ LemonLDAP::NG TOTP registration script
error: displayError, error: displayError,
success: function(data) { success: function(data) {
if (data.error) { if (data.error) {
if (data.error.match(/badCode/)) { if (data.error.match(/bad(Code|Name)/)) {
return setMsg('badCode', 'warning'); return setMsg(data.error, 'warning');
} else { } else {
return setMsg(data.error, 'danger'); return setMsg(data.error, 'danger');
} }
......
(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){if(i.error.match(/totpExistingKey/)){$("#divToHide").hide()}return d(i.error,"warning")}if(!(i.portal&&i.user&&i.secret)){return d("PE24","danger")}$("#divToHide").show();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); (function(){var displayError,getKey,setMsg,token,verify;setMsg=function(msg,level){$("#msg").html(window.translate(msg));$("#color").removeClass("message-positive message-warning message-danger alert-success alert-warning alert-danger");$("#color").addClass("message-"+level);if(level==="positive"){level="success"}return $("#color").addClass("alert-"+level)};displayError=function(j,status,err){var res;console.log("Error",err);res=JSON.parse(j.responseText);if(res&&res.error){res=res.error.replace(/.* /,"");console.log("Returned error",res);return setMsg(res,"warning")}};token="";getKey=function(reset){setMsg("yourTotpKey","warning");return $.ajax({type:"POST",url:portal+"/2fregisters/totp/getkey",dataType:"json",data:{newkey:reset},error:displayError,success:function(data){var qr,s;if(data.error){if(data.error.match(/totpExistingKey/)){$("#divToHide").hide()}return setMsg(data.error,"warning")}if(!(data.portal&&data.user&&data.secret)){return setMsg("PE24","danger")}$("#divToHide").show();s="otpauth://totp/"+escape(data.portal)+":"+escape(data.user)+"?secret="+data.secret+"&issuer="+escape(data.portal);if(data.digits!==6){s+="&digits="+data.digits}if(data.interval!==30){s+="&period="+data.interval}qr=new QRious({element:document.getElementById("qr"),value:s,size:150});$("#serialized").text(s);if(data.newkey){setMsg("yourNewTotpKey","warning")}else{setMsg("yourTotpKey","success")}return token=data.token}})};verify=function(){var val;val=$("#code").val();if(!val){return setMsg("fillTheForm","warning")}else{return $.ajax({type:"POST",url:portal+"/2fregisters/totp/verify",dataType:"json",data:{token:token,code:val,TOTPName:$("#TOTPName").val()},error:displayError,success:function(data){if(data.error){if(data.error.match(/bad(Code|Name)/)){return setMsg(data.error,"warning")}else{return setMsg(data.error,"danger")}}else{return setMsg("yourKeyIsRegistered","success")}}})}};$(document).ready(function(){getKey(0);$("#changekey").on("click",function(){return getKey(1)});return $("#verify").on("click",function(){return verify()})})}).call(this);
\ No newline at end of file
...@@ -9,7 +9,7 @@ LemonLDAP::NG U2F registration script ...@@ -9,7 +9,7 @@ LemonLDAP::NG U2F registration script
setMsg = function(msg, level) { setMsg = function(msg, level) {
$('#msg').html(window.translate(msg)); $('#msg').html(window.translate(msg));
$('#color').removeClass('message-positive message-warning alert-success alert-warning'); $('#color').removeClass('message-positive message-warning message-danger alert-success alert-warning alert-danger');
$('#color').addClass("message-" + level); $('#color').addClass("message-" + level);
if (level === 'positive') { if (level === 'positive') {
level = 'success'; level = 'success';
...@@ -62,9 +62,9 @@ LemonLDAP::NG U2F registration script ...@@ -62,9 +62,9 @@ LemonLDAP::NG U2F registration script
success: function(resp) { success: function(resp) {
if (resp.error) { if (resp.error) {
if (resp.error.match(/badName/)) { if (resp.error.match(/badName/)) {
return setMsg('badName', 'warning'); return setMsg(resp.error, 'warning');
} else { } else {
return setMsg('u2fFailed', 'warning'); return setMsg('u2fFailed', 'danger');
} }
} else if (resp.result) { } else if (resp.result) {
return setMsg('yourKeyIsRegistered', 'positive'); return setMsg('yourKeyIsRegistered', 'positive');
...@@ -101,7 +101,7 @@ LemonLDAP::NG U2F registration script ...@@ -101,7 +101,7 @@ LemonLDAP::NG U2F registration script
dataType: 'json', dataType: 'json',
success: function(resp) { success: function(resp) {
if (resp.error) { if (resp.error) {
return setMsg('u2fFailed', 'warning'); return setMsg('u2fFailed', 'danger');
} else if (resp.result) { } else if (resp.result) {
return setMsg('yourKeyIsVerified', 'positive'); return setMsg('yourKeyIsVerified', 'positive');
} }
......
(function(){var displayError,register,setMsg,verify;setMsg=function(msg,level){$("#msg").html(window.translate(msg));$("#color").removeClass("message-positive message-warning alert-success alert-warning");$("#color").addClass("message-"+level);if(level==="positive"){level="success"}return $("#color").addClass("alert-"+level)};displayError=function(j,status,err){var res;console.log("Error",err);res=JSON.parse(j.responseText);if(res&&res.error){res=res.error.replace(/.* /,"");console.log("Returned error",res);return setMsg(res,"warning")}};register=function(){return $.ajax({type:"POST",url:portal+"2fregisters/u/register",data:{},dataType:"json",error:displayError,success:function(ch){var request;request=[{challenge:ch.challenge,version:ch.version}];setMsg("touchU2fDevice","positive");$("#u2fPermission").show();return u2f.register(ch.appId,request,[],function(data){$("#u2fPermission").hide();if(data.errorCode){return setMsg(data.error,"warning")}else{return $.ajax({type:"POST",url:portal+"2fregisters/u/registration",data:{registration:JSON.stringify(data),challenge:JSON.stringify(ch),keyName:$("#keyName").val()},dataType:"json",success:function(resp){if(resp.error){if(resp.error.match(/badName/)){return setMsg("badName","warning")}else{return setMsg("u2fFailed","warning")}}else if(resp.result){return setMsg("yourKeyIsRegistered","positive")}},error:displayError})}})}})};verify=function(){return $.ajax({type:"POST",url:portal+"2fregisters/u/verify",data:{},dataType:"json",error:displayError,success:function(ch){setMsg("touchU2fDevice","positive");return u2f.sign(ch.appId,ch.challenge,ch.registeredKeys,function(data){if(data.errorCode){return setMsg("unableToGetKey","warning")}else{return $.ajax({type:"POST",url:portal+"2fregisters/u/signature",data:{signature:JSON.stringify(data),challenge:ch.challenge},dataType:"json",success:function(resp){if(resp.error){return setMsg("u2fFailed","warning")}else if(resp.result){return setMsg("yourKeyIsVerified","positive")}},error:function(j,status,err){return console.log("error",err)}})}})}})};$(document).ready(function(){$("#u2fPermission").hide();$("#register").on("click",register);$("#verify").on("click",verify);return $("#goback").attr("href",portal)})}).call(this); (function(){var displayError,register,setMsg,verify;setMsg=function(msg,level){$("#msg").html(window.translate(msg));$("#color").removeClass("message-positive message-warning message-danger alert-success alert-warning alert-danger");$("#color").addClass("message-"+level);if(level==="positive"){level="success"}return $("#color").addClass("alert-"+level)};displayError=function(j,status,err){var res;console.log("Error",err);res=JSON.parse(j.responseText);if(res&&res.error){res=res.error.replace(/.* /,"");console.log("Returned error",res);return setMsg(res,"warning")}};register=function(){return $.ajax({type:"POST",url:portal+"2fregisters/u/register",data:{},dataType:"json",error:displayError,success:function(ch){var request;request=[{challenge:ch.challenge,version:ch.version}];setMsg("touchU2fDevice","positive");$("#u2fPermission").show();return u2f.register(ch.appId,request,[],function(data){$("#u2fPermission").hide();if(data.errorCode){return setMsg(data.error,"warning")}else{return $.ajax({type:"POST",url:portal+"2fregisters/u/registration",data:{registration:JSON.stringify(data),challenge:JSON.stringify(ch),keyName:$("#keyName").val()},dataType:"json",success:function(resp){if(resp.error){if(resp.error.match(/badName/)){return setMsg(resp.error,"warning")}else{return setMsg("u2fFailed","danger")}}else if(resp.result){return setMsg("yourKeyIsRegistered","positive")}},error:displayError})}})}})};verify=function(){return $.ajax({type:"POST",url:portal+"2fregisters/u/verify",data:{},dataType:"json",error:displayError,success:function(ch){setMsg("touchU2fDevice","positive");return u2f.sign(ch.appId,ch.challenge,ch.registeredKeys,function(data){if(data.errorCode){return setMsg("unableToGetKey","warning")}else{return $.ajax({type:"POST",url:portal+"2fregisters/u/signature",data:{signature:JSON.stringify(data),challenge:ch.challenge},dataType:"json",success:function(resp){if(resp.error){return setMsg("u2fFailed","danger")}else if(resp.result){return setMsg("yourKeyIsVerified","positive")}},error:function(j,status,err){return console.log("error",err)}})}})}})};$(document).ready(function(){$("#u2fPermission").hide();$("#register").on("click",register);$("#verify").on("click",verify);return $("#goback").attr("href",portal)})}).call(this);
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