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

'Failed to create a login nonce' notification #501

Open
mikolajek opened this issue Nov 29, 2022 · 6 comments
Open

'Failed to create a login nonce' notification #501

mikolajek opened this issue Nov 29, 2022 · 6 comments

Comments

@mikolajek
Copy link

mikolajek commented Nov 29, 2022

Hi there, today, out of the blue, my site with Two-Factor 0.7.3 installed started to display the "Failed to create a login nonce" notification. I'm running WP 6.1.1 and it seems to me the latest WP upgrade (6.1 => 6.1.1) might have caused this, as I made no changes to the config myself.

I disabled the plugin by renaming its folder, but in this case, I can't log in either. The login screen just keeps refreshing and gets back to the credentials screen. Is there a way to disable the plugin and get to the WP admin screen?

BTW - I have no cache plugin and clearing just the browser cache doesn't work...

@pkevan
Copy link
Contributor

pkevan commented Jan 27, 2023

@mikolajek
Copy link
Author

Duplicate of: https://wordpress.org/support/topic/failed-to-create-a-login-nonce-message/

Correct, but no response in either place... :P

@kasparsd
Copy link
Collaborator

I haven't been able to replicate this with plugin version 0.7.3 and WP 6.1.1.

@mikolajek Which of the two-factor methods do you have enabled and which one is selected as the default?

@kasparsd
Copy link
Collaborator

There are three code paths where this error message is returned:

$login_nonce = self::create_login_nonce( $user->ID );
if ( ! $login_nonce ) {
wp_die( esc_html__( 'Failed to create a login nonce.', 'two-factor' ) );
}

if ( true === $provider->pre_process_authentication( $user ) ) {
$login_nonce = self::create_login_nonce( $user->ID );
if ( ! $login_nonce ) {
wp_die( esc_html__( 'Failed to create a login nonce.', 'two-factor' ) );
}
self::login_html( $user, $login_nonce['key'], $_REQUEST['redirect_to'], '', $provider );
exit;
}

// Ask the provider to verify the second factor.
if ( true !== $provider->validate_authentication( $user ) ) {
do_action( 'wp_login_failed', $user->user_login, new WP_Error( 'two_factor_invalid', __( 'ERROR: Invalid verification code.', 'two-factor' ) ) );
$login_nonce = self::create_login_nonce( $user->ID );
if ( ! $login_nonce ) {
wp_die( esc_html__( 'Failed to create a login nonce.', 'two-factor' ) );
}
self::login_html( $user, $login_nonce['key'], $_REQUEST['redirect_to'], esc_html__( 'ERROR: Invalid verification code.', 'two-factor' ), $provider );
exit;
}

@mikolajek
Copy link
Author

mikolajek commented Jan 27, 2023

Thanks, @kasparsd! I use Yubikey as the default method and emailed OTP as the backup one.

A question - does this plugin puts any references to other code? I mean if I remove it via FTP, do I have to make any other changes in my WP?

@dd32
Copy link
Member

dd32 commented May 3, 2023

I disabled the plugin by renaming its folder, but in this case, I can't log in either. The login screen just keeps refreshing and gets back to the credentials screen. Is there a way to disable the plugin and get to the WP admin screen?

A question - does this plugin puts any references to other code? I mean if I remove it via FTP, do I have to make any other changes in my WP?

No, renaming the plugin folder would've completely removed the plugin from the system.

This issue sounds like an issue of using an Object Cache, PHP Code cache, and/or cookie problem.. @mikolajek Did you find anything to resolve this? I'm tempted to close this issue unless some more information can be provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants