WordPress/wp-admin/js/auth-app.min.js

2 lines
2.0 KiB
JavaScript

/*! This file is auto-generated */
!function(n,l){var o=n("#app_name"),r=n("#approve"),e=n("#reject"),d=o.closest("form"),p={userLogin:l.user_login,successUrl:l.success,rejectUrl:l.reject};r.click(function(e){var i=o.val(),a=n('input[name="app_id"]',d).val();if(e.preventDefault(),!r.prop("aria-disabled"))if(0!==i.length){r.prop("aria-disabled",!0).addClass("disabled");var s={name:i};0<a.length&&(s.app_id=a),s=wp.hooks.applyFilters("wp_application_passwords_approve_app_request",s,p),wp.apiRequest({path:"/wp/v2/users/me/application-passwords?_locale=user",method:"POST",data:s}).done(function(e,a,s){wp.hooks.doAction("wp_application_passwords_approve_app_request_success",e,a,s);var o,p,t,r=l.success;r?(o=r+(-1===r.indexOf("?")?"?":"&")+"site_url="+encodeURIComponent(l.site_url)+"&user_login="+encodeURIComponent(l.user_login)+"&password="+encodeURIComponent(e.password),window.location=o):(p=wp.i18n.sprintf('<label for="new-application-password-value">'+wp.i18n.__("Your new password for %s is:")+"</label>","<strong></strong>")+' <input id="new-application-password-value" type="text" class="code" readonly="readonly" value="" />',t=n("<div></div>").attr("role","alert").attr("tabindex",-1).addClass("notice notice-success notice-alt").append(n("<p></p>").addClass("application-password-display").html(p)).append("<p>"+wp.i18n.__("Be sure to save this in a safe location. You will not be able to retrieve it.")+"</p>"),n("strong",t).text(i),n("input",t).val(e.password),d.replaceWith(t),t.focus())}).fail(function(e,a,s){var o=s,p=null;e.responseJSON&&(p=e.responseJSON).message&&(o=p.message);var t=n("<div></div>").attr("role","alert").addClass("notice notice-error").append(n("<p></p>").text(o));n("h1").after(t),r.removeProp("aria-disabled",!1).removeClass("disabled"),wp.hooks.doAction("wp_application_passwords_approve_app_request_error",p,a,s,e)})}else o.focus()}),e.click(function(e){e.preventDefault(),wp.hooks.doAction("wp_application_passwords_reject_app",p),window.location=l.reject}),d.on("submit",function(e){e.preventDefault()})}(jQuery,authApp);