Skip to content

Commit

Permalink
log out full error message
Browse files Browse the repository at this point in the history
  • Loading branch information
yizshi committed Dec 6, 2023
1 parent 3d54cf4 commit 53f608f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions class-duouniversal-wordpressplugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 3 additions & 1 deletion tests/duoUniversalAuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 53f608f

Please sign in to comment.