Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSO: Log error message from user invite response #37144

Merged
merged 23 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
afd1e4d
Log error message from user invite response
agrullon95 Apr 30, 2024
431fcc5
changelog
agrullon95 Apr 30, 2024
cdc87ba
Check for wp_error
agrullon95 May 1, 2024
9afb46e
Retrieve error message
mindbuc May 1, 2024
272d7ad
Copy changes to connection package
agrullon95 May 1, 2024
679a851
changelog
agrullon95 May 1, 2024
3ffcf9b
Connection package version update
agrullon95 May 1, 2024
f8b3e7d
Display user invite error message
agrullon95 May 1, 2024
eb42dcb
update query param key
agrullon95 May 1, 2024
6e2778e
Merge branch 'trunk' into update/invite-user-error-response-logging
agrullon95 May 1, 2024
ea4c2cf
Update logic to display error message on users screen
agrullon95 May 2, 2024
13a3de5
Merge branch 'trunk' into update/invite-user-error-response-logging
agrullon95 May 6, 2024
f484201
Sync latest sso user admin changes in Connection package
agrullon95 May 6, 2024
fc9586d
Update connection package version
agrullon95 May 6, 2024
b328072
Remove duplicate changelogs
agrullon95 May 6, 2024
35597bf
Update projects/packages/connection/src/sso/class-user-admin.php
agrullon95 May 7, 2024
26df29b
Update projects/packages/connection/src/sso/class-user-admin.php
agrullon95 May 7, 2024
aae329a
Update projects/plugins/jetpack/modules/sso/class.jetpack-sso-user-ad…
agrullon95 May 7, 2024
8829364
Update projects/plugins/jetpack/modules/sso/class.jetpack-sso-user-ad…
agrullon95 May 7, 2024
6ff596a
Display api error response for invite revoke
agrullon95 May 9, 2024
03cb174
Update revoke user invite error tracking
agrullon95 May 9, 2024
4dac85b
Merge remote-tracking branch 'origin/trunk' into update/invite-user-e…
jeherve May 10, 2024
b6a7529
Bump version
jeherve May 10, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

SSO: Improve user invite error logging
2 changes: 1 addition & 1 deletion projects/packages/connection/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"link-template": "https://github.com/Automattic/jetpack-connection/compare/v${old}...v${new}"
},
"branch-alias": {
"dev-trunk": "2.7.x-dev"
"dev-trunk": "2.8.x-dev"
},
"dependencies": {
"test-only": [
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/connection/src/class-package-version.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class Package_Version {

const PACKAGE_VERSION = '2.7.6-alpha';
const PACKAGE_VERSION = '2.8.0-alpha';

const PACKAGE_SLUG = 'connection';

Expand Down
24 changes: 18 additions & 6 deletions projects/packages/connection/src/sso/class-user-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ public function handle_invitation_results() {
return wp_admin_notice( __( 'User invite revoked successfully.', 'jetpack-connection' ), array( 'type' => 'success' ) );
}

if ( $_GET['jetpack-sso-invite-user'] === 'failed' && isset( $_GET['jetpack-sso-invite-api-error-message'] ) ) {
return wp_admin_notice( wp_kses( wp_unslash( $_GET['jetpack-sso-invite-api-error-message'] ), array() ), array( 'type' => 'error' ) );
}

if ( $_GET['jetpack-sso-invite-user'] === 'failed' && isset( $_GET['jetpack-sso-invite-error'] ) ) {
switch ( $_GET['jetpack-sso-invite-error'] ) {
case 'invalid-user':
Expand Down Expand Up @@ -261,19 +265,27 @@ public function invite_user_to_wpcom() {
);

if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
$error = 'invalid-invite-api-error';
$error_code = 'invalid-invite-api-error';
jeherve marked this conversation as resolved.
Show resolved Hide resolved
$query_params = array(
'jetpack-sso-invite-user' => 'failed',
'jetpack-sso-invite-error' => $error,
'jetpack-sso-invite-error' => $error_code,
'_wpnonce' => $nonce,
);

$tracking_event_data = array(
'success' => 'false',
'error_code' => $error_code,
);

$body = json_decode( $response['body'] );
agrullon95 marked this conversation as resolved.
Show resolved Hide resolved
jeherve marked this conversation as resolved.
Show resolved Hide resolved
if ( $body && $body->message ) {
agrullon95 marked this conversation as resolved.
Show resolved Hide resolved
$query_params['jetpack-sso-invite-api-error-message'] = $body->message;
$tracking_event_data['error_message'] = $body->message;
}

self::$tracking->record_user_event(
$event,
array(
'success' => 'false',
'error_message' => $error,
)
$tracking_event_data
);
return self::create_error_notice_and_redirect( $query_params );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/automattic-for-agencies-client/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/backup/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/boost/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/inspect/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Update invite user error response logging
4 changes: 2 additions & 2 deletions projects/plugins/jetpack/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ public function handle_invitation_results() {
return wp_admin_notice( __( 'User invite revoked successfully.', 'jetpack' ), array( 'type' => 'success' ) );
}

if ( $_GET['jetpack-sso-invite-user'] === 'failed' && isset( $_GET['jetpack-sso-invite-api-error-message'] ) ) {
return wp_admin_notice( wp_kses( wp_unslash( $_GET['jetpack-sso-invite-api-error-message'] ), array() ), array( 'type' => 'error' ) );
}

if ( $_GET['jetpack-sso-invite-user'] === 'failed' && isset( $_GET['jetpack-sso-invite-error'] ) ) {
switch ( $_GET['jetpack-sso-invite-error'] ) {
case 'invalid-user':
Expand Down Expand Up @@ -252,19 +256,27 @@ public function invite_user_to_wpcom() {
);

if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
$error = 'invalid-invite-api-error';
$error_code = 'invalid-invite-api-error';
$query_params = array(
'jetpack-sso-invite-user' => 'failed',
'jetpack-sso-invite-error' => $error,
'jetpack-sso-invite-error' => $error_code,
'_wpnonce' => $nonce,
);

$tracking_event_data = array(
'success' => 'false',
'error_code' => $error_code,
);

$body = json_decode( $response['body'] );
agrullon95 marked this conversation as resolved.
Show resolved Hide resolved
if ( $body && $body->message ) {
agrullon95 marked this conversation as resolved.
Show resolved Hide resolved
$query_params['jetpack-sso-invite-api-error-message'] = $body->message;
$tracking_event_data['error_message'] = $body->message;
}

self::$tracking->record_user_event(
$event,
array(
'success' => 'false',
'error_message' => $error,
)
$tracking_event_data
);
return self::create_error_notice_and_redirect( $query_params );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/migration/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/mu-wpcom-plugin/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/protect/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/search/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/social/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/starter-plugin/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/videopress/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading