diff options
author | Gergő Tisza <tgr.huwiki@gmail.com> | 2025-02-17 15:55:57 +0100 |
---|---|---|
committer | Gergő Tisza <tgr.huwiki@gmail.com> | 2025-02-17 17:04:31 +0100 |
commit | 8c78bad01be7658c879de851b4eede221ae2818b (patch) | |
tree | f809616ec492f32e4eb71fd674309610d3870987 | |
parent | 440d1c0e2ee65fa234d3b3f9df8555d2b738c43d (diff) | |
download | mediawikicore-8c78bad01be7658c879de851b4eede221ae2818b.tar.gz mediawikicore-8c78bad01be7658c879de851b4eede221ae2818b.zip |
auth: Log actual error message for action=login
Change-Id: I06acf62b6350f856905420263867ace754b6f79c
-rw-r--r-- | includes/api/ApiLogin.php | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/includes/api/ApiLogin.php b/includes/api/ApiLogin.php index e2e1bdac5570..f6f7aacbaa2f 100644 --- a/includes/api/ApiLogin.php +++ b/includes/api/ApiLogin.php @@ -88,6 +88,20 @@ class ApiLogin extends ApiBase { } /** + * Obtain an error code from a message, used for internal logs. + * @param Message|string|array $message + * @return string + */ + private function getErrorCode( $message ) { + $message = Message::newFromSpecifier( $message ); + if ( $message instanceof ApiMessage ) { + return $message->getApiCode(); + } else { + return $message->getKey(); + } + } + + /** * Executes the log-in attempt using the parameters passed. If * the log-in succeeds, it attaches a cookie to the session * and outputs the user id, username, and session token. If a @@ -265,7 +279,8 @@ class ApiLogin extends ApiBase { 'successful' => $authRes === 'Success', 'accountType' => $this->identityUtils->getShortUserTypeInternal( $performer ), 'loginType' => $loginType, - 'status' => $authRes, + 'status' => ( $authRes === 'Failed' && isset( $message ) ) ? $this->getErrorCode( $message ) : $authRes, + 'full_message' => isset( $message ) ? $this->formatMessage( $message ) : '', ] ); } |