jeffaknine
08/14/2023, 1:00 PMSuperTokens.getAccessToken()
returns null. Any ideas on why the session would be lost ?rp_st
08/14/2023, 1:01 PMjeffaknine
08/14/2023, 1:02 PMSuperTokens.init(apiDomain: "http://localhost:3333", apiBasePath: "/auth");
rp_st
08/14/2023, 1:03 PMjeffaknine
08/14/2023, 1:05 PMrp_st
08/14/2023, 1:05 PMjeffaknine
08/14/2023, 1:05 PMts
app.post(
`${env.COME_ON_AUTH_API_BASE_PATH}/migrate-session`,
async (req, res) => {
//This route should only be called by the new version of the app if the user is currently logged in with Firebase
// extract the access token from the request object
if (req.headers.authorization !== undefined) {
let access_token = req.headers.authorization.split("Bearer ")[1];
try {
// verify the access token and retrieve the old userId
let decodedToken: CustomClaims = (await verifyFirebaseToken(
access_token
)) as CustomClaims;
let customUserId =
decodedToken["https://hasura.io/jwt/claims"]["x-hasura-user-id"];
// create a new SuperTokens session using the customUserId
// the createNewSession function will attach the SuperTokens session tokens to the response object.
await Passwordless.signInUp({
phoneNumber: decodedToken.phone_number,
tenantId: "public",
});
await Session.createNewSession(
req,
res,
"public",
customUserId,
getHasuraCustomClaims(customUserId)
);
return res
.status(200)
.send({
message: "User successfuly migrated, please login with supertokens",
});
} catch (error) {
console.log(error);
return res
.status(500)
.send({ message: "Couldn't verify firebase token" });
}
}
// handle access_token not present in request
return res
.status(500)
.send({ message: "A jwt is required in the Authorization headers" });
}
);
jeffaknine
08/14/2023, 1:05 PMrp_st
08/14/2023, 1:06 PMrp_st
08/14/2023, 1:06 PMjeffaknine
08/14/2023, 1:07 PMjeffaknine
08/14/2023, 1:07 PMrp_st
08/14/2023, 1:08 PMjeffaknine
08/14/2023, 1:08 PMjeffaknine
08/14/2023, 1:08 PMrp_st
08/14/2023, 1:09 PMrp_st
08/14/2023, 1:09 PMjeffaknine
08/14/2023, 1:10 PMAuthorization: Bearer $firebaseToken
rp_st
08/14/2023, 1:10 PMjeffaknine
08/14/2023, 1:11 PMrp_st
08/14/2023, 1:12 PMrp_st
08/14/2023, 1:12 PMjeffaknine
08/14/2023, 1:13 PMSuperTokens.getAccessToken()
we get null
rp_st
08/14/2023, 1:13 PMSuperTokens.getAccessToken()
before the redirection, does it work?jeffaknine
08/14/2023, 1:13 PMrp_st
08/14/2023, 1:14 PMjeffaknine
08/14/2023, 1:14 PMjeffaknine
08/14/2023, 1:16 PMrp_st
08/14/2023, 1:16 PMjeffaknine
08/14/2023, 1:17 PMgetAccessToken
jeffaknine
08/14/2023, 1:17 PMjeffaknine
08/14/2023, 1:17 PMrp_st
08/14/2023, 1:18 PMrp_st
08/14/2023, 1:18 PMjeffaknine
08/14/2023, 1:23 PMrp_st
08/14/2023, 1:23 PMjeffaknine
08/14/2023, 1:24 PMjeffaknine
08/14/2023, 1:56 PMrp_st
08/14/2023, 1:57 PMjeffaknine
08/14/2023, 1:57 PMrp_st
08/14/2023, 2:01 PMjeffaknine
08/14/2023, 2:12 PMrp_st
08/14/2023, 2:13 PMjeffaknine
08/14/2023, 2:14 PMrp_st
08/14/2023, 2:14 PMrp_st
08/14/2023, 2:14 PMrp_st
08/14/2023, 2:14 PMjeffaknine
08/14/2023, 2:15 PMrp_st
08/14/2023, 2:15 PMrp_st
08/14/2023, 2:15 PMjeffaknine
08/14/2023, 2:15 PMjeffaknine
08/14/2023, 2:16 PMrp_st
08/14/2023, 2:16 PMjeffaknine
08/14/2023, 2:16 PMrp_st
08/15/2023, 12:16 PMjeffaknine
08/15/2023, 5:49 PMrp_st
08/15/2023, 6:00 PM