-
Notifications
You must be signed in to change notification settings - Fork 14
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
[WEB-2240] Remove OAuth #53
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,36 +1,26 @@ | ||
import { stytch } from "./app.js"; | ||
import { stytch } from './app.js'; | ||
|
||
// Look for the Stytch token in query params. | ||
const queryParams = new URLSearchParams(window.location.search); | ||
const token = queryParams.get("token"); | ||
const tokenType = queryParams.get("stytch_token_type"); | ||
const token = queryParams.get('token'); | ||
const tokenType = queryParams.get('stytch_token_type'); | ||
|
||
// If a token is found, authenticate it with the appropriate method. | ||
if (token && tokenType) { | ||
if (tokenType === "magic_links") { | ||
if (tokenType === 'magic_links') { | ||
stytch.magicLinks | ||
.authenticate(token, { | ||
session_duration_minutes: 60, | ||
}) | ||
.then(() => console.log("Successful authentication: Email magic link")) | ||
.then(() => console.log('Successful authentication: Email magic link')) | ||
.catch((err) => { | ||
console.error(err); | ||
alert( | ||
"Email Magic Link authentication failed. See console for details." | ||
'Email Magic Link authentication failed. See console for details.' | ||
); | ||
}); | ||
} else if (tokenType === "oauth") { | ||
stytch.oauth | ||
.authenticate(token, { | ||
session_duration_minutes: 60, | ||
}) | ||
.then(() => console.log("Successful authentication: OAuth")) | ||
.catch((err) => { | ||
console.error(err); | ||
alert("OAuth authentication failed. See console for details."); | ||
}); | ||
} | ||
} else { | ||
// If query params are not found, announce that something went wrong. | ||
alert("Something went wrong. No token found to authenticate."); | ||
alert('Something went wrong. No token found to authenticate.'); | ||
} |
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,32 +1,27 @@ | ||
import { Products } from "https://www.unpkg.com/@stytch/[email protected]/dist/index.esm.js"; | ||
import { stytch } from "./app.js"; | ||
import { Products } from 'https://www.unpkg.com/@stytch/[email protected]/dist/index.esm.js'; | ||
import { stytch } from './app.js'; | ||
|
||
const styles = { | ||
container: { | ||
width: "100%", | ||
width: '100%', | ||
}, | ||
buttons: { | ||
primary: { | ||
backgroundColor: "#4A37BE", | ||
borderColor: "#4A37BE", | ||
backgroundColor: '#4A37BE', | ||
borderColor: '#4A37BE', | ||
}, | ||
}, | ||
}; | ||
|
||
const REDIRECT_URL = "http://localhost:3000/authenticate"; | ||
const REDIRECT_URL = 'http://localhost:3000/authenticate'; | ||
const config = { | ||
products: [Products.emailMagicLinks, Products.oauth], | ||
products: [Products.emailMagicLinks], | ||
emailMagicLinksOptions: { | ||
loginRedirectURL: REDIRECT_URL, | ||
loginExpirationMinutes: 60, | ||
signupRedirectURL: REDIRECT_URL, | ||
signupExpirationMinutes: 60, | ||
}, | ||
oauthOptions: { | ||
providers: [{ type: "google" }], | ||
loginRedirectURL: REDIRECT_URL, | ||
signupRedirectURL: REDIRECT_URL, | ||
}, | ||
}; | ||
|
||
/* | ||
|
@@ -39,10 +34,10 @@ to a protected page after a user successfully logs in. | |
const callbacks = { | ||
onEvent: (message) => console.log(message), | ||
onError: (error) => console.log(error), | ||
} | ||
}; | ||
|
||
stytch.mountLogin({ | ||
elementId: "#stytch-sdk", | ||
elementId: '#stytch-sdk', | ||
styles, | ||
config, | ||
callbacks, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
User-controlled bypass of security check High