diff --git a/class-duouniversal-wordpressplugin.php b/class-duouniversal-wordpressplugin.php index 444da2b..fd94589 100644 --- a/class-duouniversal-wordpressplugin.php +++ b/class-duouniversal-wordpressplugin.php @@ -147,9 +147,14 @@ function duo_authenticate_user( $user = '', $username = '', $password = '' ) { if ( isset( $_GET['error'] ) ) { $error = $this->duo_utils->new_WP_Error( 'Duo authentication failed', - \__( 'ERROR: Error during login, please try again later.') + \__( 'ERROR: Error during login, please contact your system administrator.') ); - $this->duo_debug_log( $error->get_error_message() ); + + $error_msg = \sanitize_text_field( wp_unslash( $_GET['error'] ) ); + if ( isset( $_GET['error_description'] ) ) { + $error_msg .= ': ' . \sanitize_text_field( wp_unslash( $_GET['error_description'] ) ); + } + $this->duo_debug_log( $error_msg ); return $error; } diff --git a/tests/duoUniversalAuthenticationTest.php b/tests/duoUniversalAuthenticationTest.php index 840619a..b3aef90 100644 --- a/tests/duoUniversalAuthenticationTest.php +++ b/tests/duoUniversalAuthenticationTest.php @@ -277,12 +277,14 @@ function testAuthUserAPIErrorSet(): void ->addMethods(["get_error_message"]) ->getMock(); $this->duo_utils->method('duo_auth_enabled')->willReturn(true); - $this->duo_utils->method('new_WP_Error')->willReturn($error)->with("Duo authentication failed", "ERROR: Error during login, please try again later."); + $this->duo_utils->method('new_WP_Error')->willReturn($error)->with("Duo authentication failed", "ERROR: Error during login, please contact your system administrator."); + $authentication->expects($this->once())->method('duo_debug_log')->with($this->equalTo("test error: test description")); WP_Mock::passthruFunction('__'); WP_Mock::passthruFunction('wp_unslash'); $_GET['duo_code'] = "testcode"; $_GET['error'] = "test error"; + $_GET['error_description'] = "test description"; $result = $authentication->duo_authenticate_user(); $this->assertConditionsMet(); }