[MediaWiki-commits] [Gerrit] Pass actual message keys to MWOAuthException - change (mediawiki...OAuth)
Anomie has uploaded a new change for review. https://gerrit.wikimedia.org/r/255471 Change subject: Pass actual message keys to MWOAuthException .. Pass actual message keys to MWOAuthException For some reason MWOAuthServer was passing things that weren't defined message keys in several cases. Change-Id: I72f9a011bf138345abf9b578e4ea01ad5aaed493 --- M backend/MWOAuthServer.php M i18n/en.json M i18n/qqq.json 3 files changed, 11 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OAuth refs/changes/71/255471/1 diff --git a/backend/MWOAuthServer.php b/backend/MWOAuthServer.php index be5b5a5..c0ba27a 100644 --- a/backend/MWOAuthServer.php +++ b/backend/MWOAuthServer.php @@ -28,7 +28,7 @@ // Consumer must have a key for us to verify if ( !$consumer->get( 'secretKey' ) && !$consumer->get( 'rsaKey' ) ) { - throw new MWOAuthException( 'invalid-consumer' ); + throw new MWOAuthException( 'mwoauthserver-consumer-no-secret' ); } $this->checkSourceIP( $consumer, $request ); @@ -68,26 +68,26 @@ private function checkCallback( $consumer, $callback ) { if ( !$consumer->get( 'callbackIsPrefix' ) ) { if ( $callback !== 'oob' ) { - throw new MWOAuthException( 'callback-not-oob' ); + throw new MWOAuthException( 'mwoauth-callback-not-oob' ); } return; } if ( !$callback ) { - throw new MWOAuthException( 'callback-not-oob-or-prefix' ); + throw new MWOAuthException( 'mwoauth-callback-not-oob-or-prefix' ); } if ( $callback === 'oob' ) { return; } if ( wfParseUrl( $callback ) === null ) { - throw new MWOAuthException( 'callback-not-oob-or-prefix' ); + throw new MWOAuthException( 'mwoauth-callback-not-oob-or-prefix' ); } $consumerCallback = $consumer->get( 'callbackUrl' ); if ( substr( $callback, 0, strlen( $consumerCallback ) ) !== $consumerCallback ) { - throw new MWOAuthException( 'callback-not-oob-or-prefix' ); + throw new MWOAuthException( 'mwoauth-callback-not-oob-or-prefix' ); } return; @@ -108,7 +108,7 @@ // Consumer must have a key for us to verify if ( !$consumer->get( 'secretKey' ) && !$consumer->get( 'rsaKey' ) ) { - throw new MWOAuthException( 'invalid-consumer' ); + throw new MWOAuthException( 'mwoauthserver-consumer-no-secret' ); } $this->checkSourceIP( $consumer, $request ); @@ -118,7 +118,7 @@ if ( !$token->secret ) { // This token has a blank secret.. something is wrong - throw new MWOAuthException( 'bad-token' ); + throw new MWOAuthException( 'mwoauthdatastore-bad-token' ); } $this->check_signature( $request, $consumer, $token ); @@ -155,7 +155,7 @@ $requestIP = $request->getSourceIP(); if ( !isset( $restrictions['IPAddresses'] ) ) { - throw new MWOAuthException( 'bad-source-ip' ); // sanity; should not happen + throw new MWOAuthException( 'mwoauthdatastore-bad-source-ip' ); // sanity; should not happen } foreach ( $restrictions['IPAddresses'] as $range ) { @@ -164,7 +164,7 @@ } } - throw new MWOAuthException( 'bad-source-ip' ); + throw new MWOAuthException( 'mwoauthdatastore-bad-source-ip' ); } /** diff --git a/i18n/en.json b/i18n/en.json index 1e5f1e1..8616f1d 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -198,6 +198,7 @@ "mwoauthserver-insufficient-rights": "Your account is not allowed to use Connected Apps, contact your site administrator to find out why.\n\nInsufficient OAuth user rights, [https://www.mediawiki.org/wiki/Help:OAuth/Errors#E007 E007]", "mwoauthserver-invalid-request-token": "Invalid token in your request.", "mwoauthserver-invalid-user": "To use Connected Apps on this site, you must have an account across all projects. When you have an account on all projects, you can try to connect \"$1\" again.\n\nUnified login needed, [https://www.mediawiki.org/wiki/Help:OAuth/Errors#E008 E008]", + "mwoauthserver-consumer-no-secret": "Sorry, something went wrong connecting this application.\n\nConsumer has no secret
[MediaWiki-commits] [Gerrit] Pass actual message keys to MWOAuthException - change (mediawiki...OAuth)
jenkins-bot has submitted this change and it was merged. Change subject: Pass actual message keys to MWOAuthException .. Pass actual message keys to MWOAuthException For some reason MWOAuthServer was passing things that weren't defined message keys in several cases. Change-Id: I72f9a011bf138345abf9b578e4ea01ad5aaed493 --- M backend/MWOAuthServer.php M i18n/en.json M i18n/qqq.json 3 files changed, 11 insertions(+), 9 deletions(-) Approvals: Aaron Schulz: Looks good to me, approved Gergő Tisza: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/backend/MWOAuthServer.php b/backend/MWOAuthServer.php index be5b5a5..c0ba27a 100644 --- a/backend/MWOAuthServer.php +++ b/backend/MWOAuthServer.php @@ -28,7 +28,7 @@ // Consumer must have a key for us to verify if ( !$consumer->get( 'secretKey' ) && !$consumer->get( 'rsaKey' ) ) { - throw new MWOAuthException( 'invalid-consumer' ); + throw new MWOAuthException( 'mwoauthserver-consumer-no-secret' ); } $this->checkSourceIP( $consumer, $request ); @@ -68,26 +68,26 @@ private function checkCallback( $consumer, $callback ) { if ( !$consumer->get( 'callbackIsPrefix' ) ) { if ( $callback !== 'oob' ) { - throw new MWOAuthException( 'callback-not-oob' ); + throw new MWOAuthException( 'mwoauth-callback-not-oob' ); } return; } if ( !$callback ) { - throw new MWOAuthException( 'callback-not-oob-or-prefix' ); + throw new MWOAuthException( 'mwoauth-callback-not-oob-or-prefix' ); } if ( $callback === 'oob' ) { return; } if ( wfParseUrl( $callback ) === null ) { - throw new MWOAuthException( 'callback-not-oob-or-prefix' ); + throw new MWOAuthException( 'mwoauth-callback-not-oob-or-prefix' ); } $consumerCallback = $consumer->get( 'callbackUrl' ); if ( substr( $callback, 0, strlen( $consumerCallback ) ) !== $consumerCallback ) { - throw new MWOAuthException( 'callback-not-oob-or-prefix' ); + throw new MWOAuthException( 'mwoauth-callback-not-oob-or-prefix' ); } return; @@ -108,7 +108,7 @@ // Consumer must have a key for us to verify if ( !$consumer->get( 'secretKey' ) && !$consumer->get( 'rsaKey' ) ) { - throw new MWOAuthException( 'invalid-consumer' ); + throw new MWOAuthException( 'mwoauthserver-consumer-no-secret' ); } $this->checkSourceIP( $consumer, $request ); @@ -118,7 +118,7 @@ if ( !$token->secret ) { // This token has a blank secret.. something is wrong - throw new MWOAuthException( 'bad-token' ); + throw new MWOAuthException( 'mwoauthdatastore-bad-token' ); } $this->check_signature( $request, $consumer, $token ); @@ -155,7 +155,7 @@ $requestIP = $request->getSourceIP(); if ( !isset( $restrictions['IPAddresses'] ) ) { - throw new MWOAuthException( 'bad-source-ip' ); // sanity; should not happen + throw new MWOAuthException( 'mwoauthdatastore-bad-source-ip' ); // sanity; should not happen } foreach ( $restrictions['IPAddresses'] as $range ) { @@ -164,7 +164,7 @@ } } - throw new MWOAuthException( 'bad-source-ip' ); + throw new MWOAuthException( 'mwoauthdatastore-bad-source-ip' ); } /** diff --git a/i18n/en.json b/i18n/en.json index 1e5f1e1..8616f1d 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -198,6 +198,7 @@ "mwoauthserver-insufficient-rights": "Your account is not allowed to use Connected Apps, contact your site administrator to find out why.\n\nInsufficient OAuth user rights, [https://www.mediawiki.org/wiki/Help:OAuth/Errors#E007 E007]", "mwoauthserver-invalid-request-token": "Invalid token in your request.", "mwoauthserver-invalid-user": "To use Connected Apps on this site, you must have an account across all projects. When you have an account on all projects, you can try to connect \"$1\" again.\n\nUnified login needed, [https://www.mediawiki.org/wiki/Help:OAuth/Errors#E008 E008]", + "mwoauthserver-consumer-no-secret": "Sorry, something went wrong connecting this