Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/WorkOS/Admin/Users/AdminPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,24 @@ public function maybe_enqueue_assets( string $hook ): void {
$asset['version'] ?? WORKOS_VERSION
);

$container = workos()->getContainer();
$change_email_enabled = $container
? $container->get( \WorkOS\Auth\ChangeEmail\Controller::class )->isActive()
: false;

wp_localize_script(
self::SCRIPT_HANDLE,
'workosUsersAdmin',
[
'restUrl' => esc_url_raw( rest_url( RestApi::NAMESPACE . RestApi::BASE ) ),
'nonce' => wp_create_nonce( 'wp_rest' ),
'environment' => Config::get_active_environment(),
'environmentId' => Config::get_environment_id(),
'dashboardBaseUrl' => 'https://dashboard.workos.com',
'defaultLimit' => 25,
'pluginEnabled' => workos()->is_enabled(),
'restUrl' => esc_url_raw( rest_url( RestApi::NAMESPACE . RestApi::BASE ) ),
'changeEmailUrl' => esc_url_raw( rest_url( RestApi::NAMESPACE . '/users/' ) ),
'nonce' => wp_create_nonce( 'wp_rest' ),
'environment' => Config::get_active_environment(),
'environmentId' => Config::get_environment_id(),
'dashboardBaseUrl' => 'https://dashboard.workos.com',
'defaultLimit' => 25,
'pluginEnabled' => workos()->is_enabled(),
'changeEmailEnabled' => $change_email_enabled,
]
);

Expand All @@ -129,5 +136,10 @@ public function maybe_enqueue_assets( string $hook ): void {
// this page only needs to enqueue them.
wp_enqueue_script( \WorkOS\Auth\PasswordResetAdmin\Assets::SCRIPT_HANDLE );
wp_enqueue_style( \WorkOS\Auth\PasswordResetAdmin\Assets::STYLE_HANDLE );

// The change-email action is handled natively by the React bundle
// (own modal + in-place row refresh), so unlike password reset it
// does not enqueue the shared ChangeEmail admin handler — it just
// needs `changeEmailUrl` + `changeEmailEnabled` from the config above.
}
}
10 changes: 6 additions & 4 deletions src/WorkOS/Auth/ChangeEmail/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,17 @@ private function register_admin_assets(): void {
'nonce' => wp_create_nonce( 'wp_rest' ),
'strings' => [
'modalTitle' => __( 'Change email address', 'integration-workos' ),
'modalMessage' => __( 'A verification link will be sent to the new address. The change only commits once that link is clicked.', 'integration-workos' ),
'modalMessage' => __( 'Enter the new email address for this account.', 'integration-workos' ),
'modalInputLabel' => __( 'New email address', 'integration-workos' ),
'modalPlaceholder' => __( 'name@example.com', 'integration-workos' ),
'modalConfirm' => __( 'Send verification', 'integration-workos' ),
'modalConfirm' => __( 'Change email', 'integration-workos' ),
'modalCancel' => __( 'Cancel', 'integration-workos' ),
'sending' => __( 'Sending verification…', 'integration-workos' ),
'sending' => __( 'Saving…', 'integration-workos' ),
/* translators: %s: masked email (e.g. "j•••@e•••.com"). */
'success' => __( 'Verification email sent to %s.', 'integration-workos' ),
'errorGeneric' => __( 'Could not start the email change. Please try again.', 'integration-workos' ),
/* translators: %s: the new email address. */
'successImmediate' => __( 'Email changed to %s.', 'integration-workos' ),
'errorGeneric' => __( 'Could not change the email. Please try again.', 'integration-workos' ),
'invalidEmail' => __( 'Please enter a valid email address.', 'integration-workos' ),
],
]
Expand Down
Loading