forked from gatsbyjs/gatsby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gatsby-source-wordpress): allow using engines when using wordpres…
…s auth (gatsbyjs#38103) (gatsbyjs#38112) Co-authored-by: Lennart <lekoarts@gmail.com> (cherry picked from commit 7adb331) Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
- Loading branch information
Showing
4 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/gatsby-source-wordpress/src/steps/auth-handling.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { GatsbyNodeApiHelpers } from "~/utils/gatsby-types" | ||
import type { Step } from "./../utils/run-steps" | ||
import type { IPluginOptions } from "~/models/gatsby-api" | ||
|
||
let storedAuthSettings: IPluginOptions["auth"] | undefined | ||
|
||
export const hideAuthPluginOptions: Step = async ( | ||
_helpers: GatsbyNodeApiHelpers, | ||
pluginOptions: IPluginOptions | ||
): Promise<void> => { | ||
// store auth settings so we can restore them later | ||
storedAuthSettings = pluginOptions.auth | ||
|
||
// remove auth from pluginOptions before we write out browser plugin options module, | ||
// so we don't leak into the browser | ||
delete pluginOptions.auth | ||
} | ||
|
||
export const restoreAuthPluginOptions: Step = async ( | ||
_helpers: GatsbyNodeApiHelpers, | ||
pluginOptions: IPluginOptions | ||
): Promise<void> => { | ||
if (storedAuthSettings) { | ||
// if we stored auth settings, restore them now after we've written out browser plugin options module | ||
// so engines can use them | ||
pluginOptions.auth = storedAuthSettings | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters