This repository has been archived by the owner on Dec 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from strapi/gatsby-cloud-compatibility
Add Gatsby cloud compatibility
- Loading branch information
Showing
6 changed files
with
128 additions
and
130 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
*.log | ||
/yarn.lock | ||
node_modules | ||
.idea | ||
/authentication.js | ||
/fetch.js | ||
/normalize.js | ||
/gatsby-node.js | ||
/nodes.js | ||
/normalize.js | ||
/yarn.lock | ||
node_modules | ||
.idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,34 @@ | ||
import axios from 'axios' | ||
|
||
module.exports = async ({ loginData, reporter, apiURL }) => { | ||
let jwtToken = null | ||
|
||
// Check if loginData is set. | ||
if ( | ||
loginData.hasOwnProperty('identifier') && | ||
loginData.identifier.length !== 0 && | ||
loginData.hasOwnProperty('password') && | ||
loginData.password.length !== 0 | ||
) { | ||
const authenticationActivity = reporter.activityTimer( | ||
`Authenticate Strapi User` | ||
) | ||
authenticationActivity.start() | ||
|
||
// Define API endpoint. | ||
const loginEndpoint = `${apiURL}/auth/local` | ||
|
||
// Make API request. | ||
try { | ||
const loginResponse = await axios.post(loginEndpoint, loginData) | ||
|
||
if (loginResponse.hasOwnProperty('data')) { | ||
jwtToken = loginResponse.data.jwt | ||
} | ||
} catch (e) { | ||
reporter.panic('Strapi authentication error: ' + e) | ||
} | ||
authenticationActivity.end() | ||
} | ||
return jwtToken | ||
} |
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
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