Skip to content

Commit

Permalink
isMagicTestModeToken catches errors when token is not base64 encoded …
Browse files Browse the repository at this point in the history
…(e.g. when token is not a magic test mode token)
  • Loading branch information
gobengo committed Jan 8, 2024
1 parent a234e87 commit 0867475
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/api/src/magic.link.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ function createMagicTestmodeBypasss () {
export const magicLinkBypassForE2ETestingInTestmode = createMagicTestmodeBypasss()

function isMagicTestModeToken (token) {
const parsed = JSON.parse(globalThis.atob(token))
let parsed
try {
parsed = JSON.parse(globalThis.atob(token))
} catch (error) {
return false;
}
if (parsed.length !== 2) {
// unexpeced parse
return false
Expand Down

0 comments on commit 0867475

Please sign in to comment.