get_label(); } /** * Returns the user label for the fallback email provider. * * @return string */ public function get_user_label(): string { return esc_html__( 'Fallback email', 'defender-security' ); } /** * Get the desc of the provider. * * @return string */ public function get_description(): string { return esc_html__( 'If you ever lose your device, you can send a fallback passcode to this email address.', 'defender-security' ); } /** * Display auth method. * * @param WP_User $user The user object. */ public function user_options( WP_User $user ) { $service = $this->get_component(); $class = $service->is_checked_enabled_provider_by_slug( $user, self::$slug ) ? '' : 'hidden'; $this->get_controller()->render_partial( 'two-fa/providers/fallback-email', array( 'class' => $class, 'backup_email' => self::get_backup_email( $user->ID ), ) ); } /** * Whether this 2FA provider is configured and available for the user specified. * * @param WP_User $user WP_User object of the logged-in user. * * @return bool */ public function is_available_for_user( WP_User $user ): bool { return true; } /** * Outputs the form needed for authentication with this provider. */ public function authentication_form() { ?>

get_login_label(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>

user_email; } return $email; } /** * Whether this 2FA provider is configured and available for the user specified. * * @param WP_User $user The user object. * * @return bool|WP_Error */ public function validate_authentication( $user ) { $otp = HTTP::post( 'otp', '' ); $backup_code = get_user_meta( $user->ID, self::FALLBACK_BACKUP_CODE_KEY, true ); if ( ! empty( $backup_code ) && Crypt::compare_lines( $backup_code['code'], wp_hash( $otp ) ) && strtotime( '+3 minutes', $backup_code['time'] ) > time() ) { delete_user_meta( $user->ID, self::FALLBACK_BACKUP_CODE_KEY ); return true; } else { $lockout_message = $this->get_component()->verify_attempt( $user->ID, self::$slug ); return new WP_Error( 'opt_fail', empty( $lockout_message ) ? esc_html__( 'ERROR: Invalid passcode.', 'defender-security' ) : $lockout_message ); } } }