yzs
08/02/2022, 5:57 AMSignInUp
component from supertokens-auth-react/recipe/passwordless
redirecting to /auth
i am overriding it to only confirm OTP
by creating verify-phone
route, and adding this to frontend config signInUpFeature: { disableDefaultUI: true }
yzs
08/02/2022, 5:57 AMrp_st
08/02/2022, 5:58 AMSignInUp
from passwordless will redirect to /auth if a session does not exist already. You want to use that as a second factor correct?yzs
08/02/2022, 6:00 AMrp_st
08/02/2022, 6:01 AMforceOriginalCheck
from the userContext?yzs
08/02/2022, 6:01 AMyzs
08/02/2022, 6:01 AMyzs
08/02/2022, 6:01 AMyzs
08/02/2022, 6:01 AMyzs
08/02/2022, 6:02 AMyzs
08/02/2022, 6:02 AMrp_st
08/02/2022, 6:02 AMrp_st
08/02/2022, 6:02 AMyzs
08/02/2022, 6:02 AMrp_st
08/02/2022, 6:03 AMyzs
08/02/2022, 6:03 AMjs
SessionReact.init({
override: {
functions: oI => {
return {
...oI,
doesSessionExist: async function (input) {
let sessionExists = await oI.doesSessionExist(input)
if (!sessionExists) {
// none of the login challenges are complete. So we do not give access
return false
}
if (input.userContext.forceOriginalCheck === true) {
return true
}
if (window.location.pathname.startsWith('/auth')) {
if (window.location.pathname === '/auth/verify-phone') {
// this is a special case route where even if a session exists,
// we say it doesn't exist unless the second login challenge is solved
let accessTokenPayload =
await SessionReact.getAccessTokenPayloadSecurely()
return accessTokenPayload.phoneNumberVerified === true
}
return true
} else {
// these are routes on which the user's app pages exist. So we must allow
// access to them only when they also have their phone number verified
let accessTokenPayload =
await SessionReact.getAccessTokenPayloadSecurely()
return accessTokenPayload.phoneNumberVerified === true
}
},
}
},
},
}),
rp_st
08/02/2022, 6:05 AMyzs
08/02/2022, 6:06 AMrp_st
08/02/2022, 6:06 AMyzs
08/02/2022, 6:07 AMrp_st
08/02/2022, 6:07 AMyzs
08/02/2022, 6:08 AMrm -rf .next/ && yarn dev
so that cache is not a factorrp_st
08/02/2022, 6:08 AMyzs
08/02/2022, 6:10 AMyzs
08/02/2022, 6:11 AMyzs
08/02/2022, 6:11 AMyzs
08/02/2022, 6:12 AMrp_st
08/02/2022, 6:12 AMyzs
08/02/2022, 6:13 AMyzs
08/02/2022, 6:14 AMyzs
08/02/2022, 6:15 AMconsole.log(input)
on top of doesSessionExist
overriderp_st
08/02/2022, 6:16 AMrp_st
08/02/2022, 6:17 AMyzs
08/02/2022, 6:18 AM{ forceOriginalCheck: true }
, but it is empty objectrp_st
08/02/2022, 6:18 AMrp_st
08/02/2022, 6:19 AMyzs
08/02/2022, 6:19 AM_app.tsx
is that okay?rp_st
08/02/2022, 6:19 AMrp_st
08/02/2022, 6:19 AMrp_st
08/02/2022, 6:20 AMyzs
08/02/2022, 6:25 AMrp_st
08/02/2022, 6:25 AMrp_st
08/02/2022, 6:25 AMrp_st
08/02/2022, 6:25 AMyzs
08/02/2022, 6:25 AMrp_st
08/02/2022, 6:37 AMkey
prop to SuperTokensWrapper
which makes it recalculate the session context on path change. This is needed cause the doesSessionExist
override reads from the window pathyzs
08/02/2022, 6:58 AMyzs
08/02/2022, 6:58 AMrp_st
08/02/2022, 6:59 AMrp_st
08/02/2022, 6:59 AMyzs
08/02/2022, 6:59 AMrp_st
08/02/2022, 6:59 AMyzs
08/02/2022, 7:11 AMyzs
08/02/2022, 7:12 AM/auth?lang=somelang
, it redirects to /auth
without query paramsrp_st
08/02/2022, 7:13 AMyzs
08/02/2022, 7:13 AMyzs
08/02/2022, 7:13 AMrp_st
08/02/2022, 7:13 AM