PHP 8.1.33
Preview: auth-app.js Size: 5.66 KB
/home/jambtst2015/public_html/greymouthconsulting.com/wp-admin/js/auth-app.js

/**
 * @output wp-admin/js/auth-app.js
 */

/* global authApp */

( function( $, authApp ) {
	var $appNameField = $( '#app_name' ),
		$approveBtn = $( '#approve' ),
		$rejectBtn = $( '#reject' ),
		$form = $appNameField.closest( 'form' ),
		context = {
			userLogin: authApp.user_login,
			successUrl: authApp.success,
			rejectUrl: authApp.reject
		};

	$approveBtn.on( 'click', function( e ) {
		var name = $appNameField.val(),
			appId = $( 'input[name="app_id"]', $form ).val();

		e.preventDefault();

		if ( $approveBtn.prop( 'aria-disabled' ) ) {
			return;
		}

		if ( 0 === name.length ) {
			$appNameField.trigger( 'focus' );
			return;
		}

		$approveBtn.prop( 'aria-disabled', true ).addClass( 'disabled' );

		var request = {
			name: name
		};

		if ( appId.length > 0 ) {
			request.app_id = appId;
		}

		/**
		 * Filters the request data used to Authorize an Application Password request.
		 *
		 * @since 5.6.0
		 *
		 * @param {Object} request            The request data.
		 * @param {Object} context            Context about the Application Password request.
		 * @param {string} context.userLogin  The user's login username.
		 * @param {string} context.successUrl The URL the user will be redirected to after approving the request.
		 * @param {string} context.rejectUrl  The URL the user will be redirected to after rejecting the request.
		 */
		request = wp.hooks.applyFilters( 'wp_application_passwords_approve_app_request', request, context );

		wp.apiRequest( {
			path: '/wp/v2/users/me/application-passwords?_locale=user',
			method: 'POST',
			data: request
		} ).done( function( response, textStatus, jqXHR ) {

			/**
			 * Fires when an Authorize Application Password request has been successfully approved.
			 *
			 * In most cases, this should be used in combination with the {@see 'wp_authorize_application_password_form_approved_no_js'}
			 * action to ensure that both the JS and no-JS variants are handled.
			 *
			 * @since 5.6.0
			 *
			 * @param {Object} response          The response from the REST API.
			 * @param {string} response.password The newly created password.
			 * @param {string} textStatus        The status of the request.
			 * @param {jqXHR}  jqXHR             The underlying jqXHR object that made the request.
			 */
			wp.hooks.doAction( 'wp_application_passwords_approve_app_request_success', response, textStatus, jqXHR );

			var raw = authApp.success,
				url, message, $notice;

			if ( raw ) {
				url = raw + ( -1 === raw.indexOf( '?' ) ? '?' : '&' ) +
					'site_url=' + encodeURIComponent( authApp.site_url ) +
					'&user_login=' + encodeURIComponent( authApp.user_login ) +
					'&password=' + encodeURIComponent( response.password );

				window.location = url;
			} else {
				message = wp.i18n.sprintf(
					/* translators: %s: Application name. */
					'<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="" />';
				$notice = $( '<div></div>' )
					.attr( 'role', 'alert' )
					.attr( 'tabindex', -1 )
					.addClass( 'notice notice-success notice-alt' )
					.append( $( '<p></p>' ).addClass( 'application-password-display' ).html( message ) )
					.append( '<p>' + wp.i18n.__( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ) + '</p>' );

				// We're using .text() to write the variables to avoid any chance of XSS.
				$( 'strong', $notice ).text( response.name );
				$( 'input', $notice ).val( response.password );

				$form.replaceWith( $notice );
				$notice.trigger( 'focus' );
			}
		} ).fail( function( jqXHR, textStatus, errorThrown ) {
			var errorMessage = errorThrown,
				error = null;

			if ( jqXHR.responseJSON ) {
				error = jqXHR.responseJSON;

				if ( error.message ) {
					errorMessage = error.message;
				}
			}

			var $notice = $( '<div></div>' )
				.attr( 'role', 'alert' )
				.addClass( 'notice notice-error' )
				.append( $( '<p></p>' ).text( errorMessage ) );

			$( 'h1' ).after( $notice );

			$approveBtn.removeProp( 'aria-disabled', false ).removeClass( 'disabled' );

			/**
			 * Fires when an Authorize Application Password request encountered an error when trying to approve the request.
			 *
			 * @since 5.6.0
			 * @since 5.6.1 Corrected action name and signature.
			 *
			 * @param {Object|null} error       The error from the REST API. May be null if the server did not send proper JSON.
			 * @param {string}      textStatus  The status of the request.
			 * @param {string}      errorThrown The error message associated with the response status code.
			 * @param {jqXHR}       jqXHR       The underlying jqXHR object that made the request.
			 */
			wp.hooks.doAction( 'wp_application_passwords_approve_app_request_error', error, textStatus, errorThrown, jqXHR );
		} );
	} );

	$rejectBtn.on( 'click', function( e ) {
		e.preventDefault();

		/**
		 * Fires when an Authorize Application Password request has been rejected by the user.
		 *
		 * @since 5.6.0
		 *
		 * @param {Object} context            Context about the Application Password request.
		 * @param {string} context.userLogin  The user's login username.
		 * @param {string} context.successUrl The URL the user will be redirected to after approving the request.
		 * @param {string} context.rejectUrl  The URL the user will be redirected to after rejecting the request.
		 */
		wp.hooks.doAction( 'wp_application_passwords_reject_app', context );

		// @todo: Make a better way to do this so it feels like less of a semi-open redirect.
		window.location = authApp.reject;
	} );

	$form.on( 'submit', function( e ) {
		e.preventDefault();
	} );
}( jQuery, authApp ) );

Directory Contents

Dirs: 1 × Files: 97

Name Size Perms Modified Actions
widgets DIR
- drwxr-xr-x 2024-11-22 17:53:04
Edit Download
2.86 KB lrw-r--r-- 2024-10-13 23:09:12
Edit Download
758 B lrw-r--r-- 2025-02-06 22:27:26
Edit Download
6.24 KB lrw-r--r-- 2023-09-18 02:51:24
Edit Download
2.95 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
5.66 KB lrw-r--r-- 2021-02-24 00:45:04
Edit Download
2.04 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
11.32 KB lrw-r--r-- 2020-07-28 03:35:02
Edit Download
3.01 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
9.54 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
3.40 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
2.85 KB lrw-r--r-- 2024-02-12 00:14:20
Edit Download
1.28 KB lrw-r--r-- 2022-04-09 00:07:18
Edit Download
61.15 KB lrw-r--r-- 2025-04-25 22:38:30
Edit Download
23.12 KB lrw-r--r-- 2025-04-25 22:38:30
Edit Download
3.35 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
1.18 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
1.98 KB lrw-r--r-- 2021-02-24 00:45:04
Edit Download
287.36 KB lrw-r--r-- 2024-12-23 01:46:28
Edit Download
109.14 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
111.13 KB lrw-r--r-- 2025-09-30 21:01:30
Edit Download
46.93 KB lrw-r--r-- 2025-09-30 21:01:30
Edit Download
70.05 KB lrw-r--r-- 2024-06-21 22:17:14
Edit Download
27.41 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
27.02 KB lrw-r--r-- 2025-03-16 23:40:32
Edit Download
8.65 KB lrw-r--r-- 2025-03-16 23:40:32
Edit Download
37.12 KB lrw-r--r-- 2024-12-14 06:32:18
Edit Download
15.13 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
41.61 KB lrw-r--r-- 2024-04-12 21:47:14
Edit Download
13.14 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
43.98 KB lrw-r--r-- 2025-04-25 22:28:30
Edit Download
12.76 KB lrw-r--r-- 2025-04-25 22:28:30
Edit Download
7.67 KB lrw-r--r-- 2023-07-18 02:03:26
Edit Download
5.41 KB lrw-r--r-- 2023-10-10 01:31:28
Edit Download
3.65 KB lrw-r--r-- 2023-10-10 01:31:28
Edit Download
39.98 KB lrw-r--r-- 2024-08-28 20:45:12
Edit Download
15.15 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
20.17 KB lrw-r--r-- 2024-09-30 22:24:14
Edit Download
9.41 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
7.61 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
2.93 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
23.09 KB lrw-r--r-- 2021-11-03 23:40:00
Edit Download
890 B lrw-r--r-- 2021-02-24 00:45:04
Edit Download
423 B lrw-r--r-- 2021-02-24 00:45:04
Edit Download
3.89 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
1.70 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
1.27 KB lrw-r--r-- 2021-02-24 00:45:04
Edit Download
611 B lrw-r--r-- 2022-04-09 00:07:18
Edit Download
3.38 KB lrw-r--r-- 2021-01-22 17:32:04
Edit Download
1.13 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
6.61 KB lrw-r--r-- 2024-10-07 06:49:18
Edit Download
2.38 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
60.72 KB lrw-r--r-- 2025-09-30 21:01:30
Edit Download
29.85 KB lrw-r--r-- 2025-09-30 21:01:30
Edit Download
4.14 KB lrw-r--r-- 2021-01-22 17:32:04
Edit Download
1.10 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
1.31 KB lrw-r--r-- 2023-06-24 03:09:30
Edit Download
847 B lrw-r--r-- 2025-02-06 22:27:26
Edit Download
6.92 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
2.35 KB lrw-r--r-- 2023-02-02 21:36:32
Edit Download
38.68 KB lrw-r--r-- 2024-11-23 01:10:24
Edit Download
18.40 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
18.49 KB lrw-r--r-- 2025-03-16 23:40:32
Edit Download
6.60 KB lrw-r--r-- 2025-03-16 23:40:32
Edit Download
10.67 KB lrw-r--r-- 2024-06-21 22:17:14
Edit Download
5.03 KB lrw-r--r-- 2024-06-21 22:17:14
Edit Download
33.92 KB lrw-r--r-- 2024-10-14 00:49:14
Edit Download
17.97 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
876 B lrw-r--r-- 2020-07-07 22:55:04
Edit Download
620 B lrw-r--r-- 2020-07-07 22:55:04
Edit Download
13.15 KB lrw-r--r-- 2023-12-28 20:27:16
Edit Download
6.13 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
6.10 KB lrw-r--r-- 2024-08-24 02:47:16
Edit Download
2.20 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
3.20 KB lrw-r--r-- 2024-09-08 02:44:18
Edit Download
1.53 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
10.88 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
3.00 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
5.64 KB lrw-r--r-- 2024-02-19 03:16:14
Edit Download
2.22 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
4.85 KB lrw-r--r-- 2025-03-10 22:16:28
Edit Download
2.04 KB lrw-r--r-- 2025-03-10 22:16:28
Edit Download
24.77 KB lrw-r--r-- 2025-02-08 20:53:18
Edit Download
11.43 KB lrw-r--r-- 2025-02-08 20:53:18
Edit Download
54.67 KB lrw-r--r-- 2025-03-10 22:16:28
Edit Download
26.42 KB lrw-r--r-- 2025-03-10 22:16:28
Edit Download
109.33 KB lrw-r--r-- 2025-02-08 20:53:18
Edit Download
47.27 KB lrw-r--r-- 2025-02-08 20:53:18
Edit Download
15.00 KB lrw-r--r-- 2024-09-18 04:14:14
Edit Download
6.70 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
2.25 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
676 B lrw-r--r-- 2025-02-06 22:27:26
Edit Download
22.56 KB lrw-r--r-- 2021-03-18 23:01:04
Edit Download
12.31 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
7.52 KB lrw-r--r-- 2020-07-28 03:35:02
Edit Download
1.49 KB lrw-r--r-- 2025-02-06 22:27:26
Edit Download
740 B lrw-r--r-- 2021-03-18 23:01:04
Edit Download
458 B lrw-r--r-- 2021-03-18 23:01:04
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).