lemonldap-ng/lemonldap-ng-portal/site/htdocs/static/common/js/2fregistration.min.js

1 line
1.3 KiB
JavaScript

!function(){var o=function(e,r){return $("#msg").attr("trspan",e),$("#msg").html(window.translate(e)),$("#color").removeClass("message-positive message-warning alert-success alert-warning"),$("#color").addClass("message-"+r),"positive"===r&&(r="success"),$("#color").addClass("alert-"+r),$("#color").attr("role","status")},e=function(e,r,t){if(console.log("Error",t),(e=JSON.parse(e.responseText))&&e.error)return e=e.error.replace(/.* /,""),console.log("Returned error",e),e.match(/module/)?o("notAuthorized","warning"):o(e,"warning")},r=function(r,t){return"U2F"===r?r="u":"UBK"===r?r="yubikey":"TOTP"===r?r="totp":"WebAuthn"===r?r="webauthn":o("u2fFailed","warning"),$.ajax({type:"POST",url:portal+"2fregisters/"+r+"/delete",data:{epoch:t},dataType:"json",error:e,success:function(e){return e.error?e.error.match(/notAuthorized/)?o("notAuthorized","warning"):o("unknownAction","warning"):e.result?($("#delete-"+t).hide(),$(document).trigger("mfaDeleted",[{type:r,epoch:t}]),o("yourKeyIsUnregistered","positive")):void 0}})};$(document).ready(function(){return $("body").on("click",".remove2f",function(){return r($(this).attr("device"),$(this).attr("epoch"))}),$("#goback").attr("href",portal),$(".data-epoch").each(function(){var e=new Date(1e3*$(this).text());return $(this).text(e.toLocaleString())})})}.call(this);