get_label(); } /** * @return string */ public function get_user_label() { return __( 'Fallback email', 'wpdef' ); } /** * Get the desc of the provider. * * @return string */ public function get_description() { return __( 'If you ever lose your device, you can send a fallback passcode to this email address.', 'wpdef' ); } /** * Display auth method. * * @param WP_User $user */ public function user_options( $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 boolean */ public function is_available_for_user( $user ) { return true; } public function authentication_form() { ?>
get_label(); ?>
user_email; } return $email; } /** * Whether this 2FA provider is configured and available for the user specified. * * @param WP_User $user * * @return bool|\WP_Error */ public function validate_authentication( $user ) { $otp = HTTP::post( 'otp' ); $backup_code = get_user_meta( $user->ID, 'defenderBackupCode', true ); if ( ! empty( $backup_code ) && $backup_code['code'] === $otp && strtotime( '+3 minutes', $backup_code['time'] ) > time() ) { delete_user_meta( $user->ID, 'defenderBackupCode' ); return true; } else { return new \WP_Error( 'opt_fail', __( 'ERROR: Invalid passcode.', 'wpdef' ) ); } } }