text: $(document).on("change","#2fa",function(){var n=$(this).prop("checked");if(n)var a="Enable Two Factor Auth",r=!0;else a="Disable Two Factor Auth",r=!1;swal({title:a,text:"Please enter your current password to continue. If you do not know your current password, logout and click 'Forgot Password' on the login page.",input:"password",inputAttributes:{autocapitalize:"off",autocorrect:"off"},showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"Continue",cancelButtonText:"Cancel",confirmButtonClass:"btn btn-success",cancelButtonClass:"btn btn-danger",buttonsStyling:!0,reverseButtons:!0,preConfirm:function(t){return new Promise(function(e,o){DappurCSRF.csrfAjax("/profile/2fa",{password:t,status2fa:r},function(t){if(parsed=jQuery.parseJSON(t),"error"==parsed.result){o("Your current password doesn't match. If you do not know your current password, logout and click 'Forgot Password' on the login page.")}else"success"==parsed.result?swal({title:a,html:'Please scan the following QR code or enter the secret into your authenticator app and enter the code you receive to enable two factor authentication.<br /><img src="'+parsed.qr+'" style="max-width: 100%" /><br /><b>Secret: </b>'+parsed.secret+'<br /><div class="row"><div class="col-md-6 col-md-offset-3"><input type="number" id="swal-input1" style="text-align: center;" class="swal2-input form-control" placeholder="Code"></div></div>',showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"Continue",cancelButtonText:"Cancel",confirmButtonClass:"btn btn-success",cancelButtonClass:"btn btn-danger",buttonsStyling:!0,reverseButtons:!0,preConfirm:function(){return new Promise(function(e,o){var t=$("#swal-input1").val();DappurCSRF.csrfAjax("/profile/2fa/validate",{code:t},function(t){parsed=jQuery.parseJSON(t),"error"==parsed.result?o("Code incorrect, please try again."):"success"==parsed.result?e():o("An unknown error occured.")})})}}).then(function(){swal({type:"success",title:"Two factor authentication has been successfully set up on your account."})},function(t){var e="checked";if(n)e="";$("#2fa-toggle").html('<input type="checkbox" '+e+' data-toggle="toggle" data-on="Enabled" data-off="Disabled" data-onstyle="success" data-offstyle="danger" height="" id="2fa">'),$("#2fa").bootstrapToggle()}).catch(swal.noop):"disabled"==parsed.result&&e()})})},allowOutsideClick:!1}).then(function(){},function(t){var e="checked";if(n)e="";$("#2fa-toggle").html('<input type="checkbox" '+e+' data-toggle="toggle" data-on="Enabled" data-off="Disabled" data-onstyle="success" data-offstyle="danger" height="" id="2fa">'),$("#2fa").bootstrapToggle()}).catch(swal.noop)});
  