Code Duplication    Length = 12-13 lines in 2 locations

projects/packages/sync/src/class-rest-endpoints.php 1 location

@@ 711-723 (lines=13) @@
708
	 *
709
	 * @return bool Whether user has capability 'manage_options' or a blog token is used.
710
	 */
711
	public static function verify_default_permissions() {
712
		if ( current_user_can( 'manage_options' ) || Rest_Authentication::is_signed_with_blog_token() ) {
713
			return true;
714
		}
715
716
		$error_msg = esc_html__(
717
			'You do not have the correct user permissions to perform this action.
718
			Please contact your site admin if you think this is a mistake.',
719
			'jetpack'
720
		);
721
722
		return new WP_Error( 'invalid_user_permission_sync', $error_msg, array( 'status' => rest_authorization_required_code() ) );
723
	}
724
725
	/**
726
	 * Validate Queue name.

projects/packages/backup/src/class-rest-controller.php 1 location

@@ 190-201 (lines=12) @@
187
	 *
188
	 * @return bool|WP_Error True if a blog token was used to sign the request, WP_Error otherwise.
189
	 */
190
	public static function backup_permissions_callback() {
191
		if ( Rest_Authentication::is_signed_with_blog_token() ) {
192
			return true;
193
		}
194
195
		$error_msg = esc_html__(
196
			'You are not allowed to perform this action.',
197
			'jetpack'
198
		);
199
200
		return new WP_Error( 'rest_forbidden', $error_msg, array( 'status' => rest_authorization_required_code() ) );
201
	}
202
203
	/**
204
	 * Install the Backup Helper Script.