alen_george
10/20/2022, 6:12 AMnkshah2
10/20/2022, 6:15 AMalen_george
10/20/2022, 6:17 AMnkshah2
10/20/2022, 6:17 AMalen_george
10/20/2022, 6:18 AMnkshah2
10/20/2022, 6:18 AMalen_george
10/20/2022, 6:18 AMalen_george
10/20/2022, 6:23 AMnkshah2
10/20/2022, 6:24 AMPasswordless.createCode
for example) you can use the preApiHook
feature to pass additional params
It would look similar to this
Passwordless.createCode({
email: "", // or phone
options: {
preAPIHook: async (input) => {
// Modify input.requestInit
return {
url: input.url,
requestInit: input.requestInit
};
},
},
})
This way you can customise the payload, url etc of the network requestnkshah2
10/20/2022, 6:27 AMnkshah2
10/20/2022, 6:28 AMalen_george
10/20/2022, 6:49 AMnkshah2
10/20/2022, 6:49 AMrp_st
10/20/2022, 7:16 AMrp_st
10/20/2022, 7:16 AMalen_george
10/20/2022, 7:17 AMalen_george
10/20/2022, 8:14 AMemailDelivery: {
override: (originalImplementation) => {
return {
...originalImplementation,
sendEmail: async function ({
codeLifetime, // amount of time the code is alive for (in MS)
email,
urlWithLinkCode, // magic link
userInputCode, // OTP
}) {}
rp_st
10/20/2022, 8:15 AMrp_st
10/20/2022, 8:15 AMalen_george
10/20/2022, 9:19 AMalen_george
10/20/2022, 10:19 AMError: Please provide a valid sessionScope
Could you please help me with this issue.rp_st
10/20/2022, 10:23 AMtypeof window !== "undefined"
alen_george
10/20/2022, 10:33 AMawait Session.getUserId()
, Should this also be run in frontend only ?rp_st
10/20/2022, 11:08 AMalen_george
10/21/2022, 3:04 AMrp_st
10/21/2022, 3:15 AMrp_st
10/21/2022, 3:16 AMalen_george
10/21/2022, 9:04 AMalen_george
10/21/2022, 9:04 AMrp_st
10/21/2022, 9:05 AMalen_george
10/21/2022, 9:05 AMalen_george
10/21/2022, 9:05 AMrp_st
10/21/2022, 9:06 AMalen_george
10/21/2022, 9:07 AMrp_st
10/21/2022, 9:08 AMalen_george
10/21/2022, 9:08 AMalen_george
10/21/2022, 9:47 AMrp_st
10/21/2022, 9:48 AMalen_george
10/21/2022, 9:48 AMrp_st
10/21/2022, 9:48 AMalen_george
10/21/2022, 9:48 AMalen_george
10/21/2022, 9:49 AMrp_st
10/21/2022, 9:49 AMalen_george
10/21/2022, 9:50 AMrp_st
10/21/2022, 9:51 AMalen_george
10/21/2022, 9:51 AMrp_st
10/21/2022, 9:52 AMalen_george
10/21/2022, 9:52 AMalen_george
10/21/2022, 9:52 AMrp_st
10/21/2022, 9:52 AMrp_st
10/21/2022, 9:52 AMalen_george
10/21/2022, 9:53 AMrp_st
10/21/2022, 9:53 AMalen_george
10/21/2022, 9:53 AMalen_george
10/21/2022, 9:53 AMrp_st
10/21/2022, 9:54 AMrp_st
10/21/2022, 9:54 AMalen_george
10/21/2022, 9:54 AMrp_st
10/21/2022, 9:54 AMrp_st
10/21/2022, 9:54 AMalen_george
10/21/2022, 9:54 AMrp_st
10/21/2022, 9:54 AMalen_george
10/21/2022, 10:34 AMrp_st
10/21/2022, 10:39 AMalen_george
10/21/2022, 10:46 AMalen_george
10/21/2022, 10:52 AMrp_st
10/21/2022, 10:53 AMrp_st
10/21/2022, 10:53 AMrp_st
10/21/2022, 10:53 AMrp_st
10/21/2022, 10:53 AMalen_george
10/21/2022, 10:54 AMrp_st
10/21/2022, 10:54 AMrp_st
10/24/2022, 5:49 PMalen_george
10/25/2022, 3:50 AMalen_george
10/25/2022, 4:04 AMawait Session.signout()
it's not clearing the cookies properly. Due to which when I check if Session exist or not it returns true and takes me to dashboard.alen_george
10/25/2022, 4:04 AMrp_st
10/25/2022, 4:05 AMalen_george
10/25/2022, 4:05 AMrp_st
10/25/2022, 4:05 AMalen_george
10/25/2022, 4:06 AMalen_george
10/25/2022, 11:42 AMrp_st
10/25/2022, 11:46 AMalen_george
10/25/2022, 11:48 AMawait Session.signout()
function from frontend.alen_george
10/25/2022, 11:48 AMrp_st
10/25/2022, 11:49 AMrp_st
10/25/2022, 11:49 AMrp_st
10/25/2022, 11:49 AMalen_george
10/25/2022, 11:51 AMrp_st
10/25/2022, 11:52 AMrp_st
10/25/2022, 11:52 AMalen_george
10/25/2022, 11:54 AMalen_george
10/25/2022, 11:54 AMalen_george
10/25/2022, 11:54 AMrp_st
10/25/2022, 11:55 AMalen_george
10/25/2022, 11:55 AMrp_st
10/25/2022, 11:56 AMalen_george
10/25/2022, 11:58 AMrp_st
10/25/2022, 11:58 AMrp_st
10/25/2022, 11:59 AMalen_george
10/25/2022, 12:01 PMalen_george
10/25/2022, 12:01 PMrp_st
10/25/2022, 12:03 PMrp_st
10/25/2022, 12:03 PMalen_george
10/25/2022, 12:03 PMalen_george
10/25/2022, 12:03 PMalen_george
10/25/2022, 12:10 PMalen_george
10/25/2022, 12:10 PMalen_george
10/25/2022, 12:15 PMalen_george
10/25/2022, 12:16 PMalen_george
10/25/2022, 12:16 PMnkshah2
10/25/2022, 12:17 PMalen_george
10/25/2022, 12:17 PMalen_george
10/25/2022, 12:17 PMalen_george
10/25/2022, 12:18 PMSuperTokens.init({
appInfo: {
apiDomain: Constants.SUPERTOKENS_SVC_URL,
apiBasePath: "/auth",
appName: "blocksurvey",
},
recipeList: [
Session.init(),
Passwordless.init()
],
});
alen_george
10/25/2022, 12:18 PMsupertokens.init({
framework: 'express',
supertokens: {
// These are the connection details of the app you created on supertokens.com
connectionURI: config.supertokensConfig.connection_url,
apiKey: config.supertokensConfig.api_key,
},
appInfo: {
// learn more about this on https://supertokens.com/docs/session/appinfo
appName: 'blocksurvey',
apiDomain: apiDomain,
websiteDomain: websiteDomain,
apiBasePath: '/auth',
websiteBasePath: '/signin',
},
recipeList: [
Passwordless.init({
flowType: 'USER_INPUT_CODE_AND_MAGIC_LINK',
contactMethod: 'EMAIL',
alen_george
10/25/2022, 12:20 PMnkshah2
10/25/2022, 12:21 PMConstants.SUPERTOKENS_SVC_URL
on the frontend and websiteDomain
on the backend?alen_george
10/25/2022, 12:22 PMalen_george
10/25/2022, 12:28 PMalen_george
10/25/2022, 12:28 PMrp_st
10/25/2022, 12:29 PMrp_st
10/25/2022, 12:31 PMrp_st
10/25/2022, 12:32 PMalen_george
10/25/2022, 12:33 PMrp_st
10/25/2022, 12:33 PMrp_st
10/25/2022, 12:33 PMrp_st
10/25/2022, 12:34 PMrp_st
10/25/2022, 12:34 PMalen_george
10/25/2022, 12:34 PMalen_george
10/25/2022, 12:35 PMrp_st
10/25/2022, 12:37 PMrp_st
10/25/2022, 12:38 PMrp_st
10/25/2022, 12:38 PMalen_george
10/25/2022, 12:39 PMrp_st
10/25/2022, 12:39 PMrp_st
10/25/2022, 12:39 PMrp_st
10/25/2022, 12:39 PMrp_st
10/25/2022, 12:40 PMrp_st
10/25/2022, 12:40 PMalen_george
10/25/2022, 12:43 PMalen_george
10/25/2022, 12:43 PMalen_george
10/25/2022, 12:44 PMrp_st
10/25/2022, 12:45 PMrp_st
10/25/2022, 12:45 PMrp_st
10/25/2022, 12:45 PMalen_george
10/25/2022, 12:47 PMrp_st
10/25/2022, 12:54 PMalen_george
10/25/2022, 12:59 PMalen_george
10/25/2022, 1:02 PMrp_st
10/25/2022, 1:11 PMrp_st
10/25/2022, 1:11 PMalen_george
10/25/2022, 1:15 PMalen_george
10/26/2022, 7:17 AMrp_st
10/26/2022, 7:19 AMrp_st
10/26/2022, 7:20 AMrp_st
10/26/2022, 7:20 AMalen_george
10/26/2022, 7:21 AMrp_st
10/26/2022, 7:21 AMalen_george
10/26/2022, 7:21 AMrp_st
10/26/2022, 7:23 AMalen_george
10/26/2022, 7:24 AMalen_george
10/26/2022, 7:26 AM"supertokens-auth-react/recipe/passwordless"
. Instead I use supertokens-web-js/recipe/passwordless
. Will it create any issue?rp_st
10/26/2022, 7:27 AMalen_george
10/26/2022, 7:28 AMrp_st
10/26/2022, 7:29 AMts
Passwordless.createCode({
email: "...",
options: {
preAPIHook: async (context) => {
// TODO: modify request body in context
return context;
}
}
})
alen_george
10/26/2022, 7:29 AMrp_st
10/26/2022, 7:30 AMcreateCode
functionalen_george
10/26/2022, 7:30 AMalen_george
10/26/2022, 7:32 AMrp_st
10/26/2022, 7:33 AMrp_st
10/26/2022, 7:34 AMalen_george
10/26/2022, 7:34 AMalen_george
10/26/2022, 8:55 AMhttp://localhost:4200/signin?rid=passwordless&preAuthSessionId=WvK4-jhGS2O1zIc13Ba7P1nhu-HuZ_BCLDQqC-djGTY=#yvtA3M0PM2sl3Qhi-3j2CYEZy1OXqE5uNFr3brzU5A4=&redirectTo=true
I have added an extra query param redirectTo=true
. But while validating the url and consuming it. The backend is throwing an error :
Error: SuperTokens core threw an error for a POST request to path: '/recipe/signinup/code/consume' with status code: 400 and message: Input encoding error in linkCode
at Querier.<anonymous> (C:\supertoken-function\node_modules\supertokens-node\lib\build\querier.js:252:31)
at Generator.throw (<anonymous>)
at rejected (C:\supertoken-function\node_modules\supertokens-node\lib\build\querier.js:22:44)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
alen_george
10/26/2022, 8:55 AMrp_st
10/26/2022, 8:57 AMrp_st
10/26/2022, 8:57 AMrp_st
10/26/2022, 8:58 AMalen_george
10/26/2022, 8:58 AMalen_george
10/26/2022, 8:58 AMrp_st
10/26/2022, 8:59 AMrp_st
10/26/2022, 8:59 AMrp_st
10/26/2022, 8:59 AMalen_george
10/26/2022, 8:59 AMalen_george
10/26/2022, 9:00 AMalen_george
10/26/2022, 9:01 AMhttp://localhost:4200/signin?redirectTo=true&rid=passwordless&preAuthSessionId=WvK4-jhGS2O1zIc13Ba7P1nhu-HuZ_BCLDQqC-djGTY%3D#yvtA3M0PM2sl3Qhi-3j2CYEZy1OXqE5uNFr3brzU5A4&=
alen_george
10/26/2022, 9:01 AMrp_st
10/26/2022, 9:01 AMalen_george
10/26/2022, 9:02 AMalen_george
10/26/2022, 9:02 AMrp_st
10/26/2022, 9:02 AMalen_george
10/26/2022, 9:02 AMrp_st
10/26/2022, 9:03 AMrp_st
10/26/2022, 9:03 AMalen_george
10/26/2022, 9:03 AMalen_george
10/26/2022, 9:03 AMrp_st
10/26/2022, 9:04 AMalen_george
11/24/2022, 8:04 AM{
status: "failed",
message: "Access token has expired. Please call the refresh API"
}
alen_george
11/24/2022, 8:04 AMalen_george
11/24/2022, 8:06 AMalen_george
11/24/2022, 8:06 AMrp_st
11/24/2022, 8:15 AMrp_st
11/24/2022, 8:15 AMrp_st
11/24/2022, 8:15 AMalen_george
11/24/2022, 8:19 AMalen_george
11/24/2022, 8:19 AMalen_george
11/24/2022, 8:23 AMalen_george
11/24/2022, 8:24 AMrp_st
11/24/2022, 8:28 AMalen_george
11/24/2022, 8:29 AMalen_george
11/24/2022, 8:30 AMlet session = await Session.getSession(req, res);
let userId = session.getUserId();
alen_george
11/24/2022, 8:31 AMrp_st
11/24/2022, 8:31 AMalen_george
11/24/2022, 8:31 AMrp_st
11/24/2022, 8:31 AMalen_george
11/24/2022, 8:31 AMrp_st
11/24/2022, 8:31 AMrp_st
11/24/2022, 8:32 AMalen_george
11/24/2022, 8:32 AMalen_george
11/24/2022, 8:33 AMalen_george
11/24/2022, 8:33 AMrp_st
11/24/2022, 8:33 AMrp_st
11/24/2022, 8:33 AMrp_st
11/24/2022, 8:33 AMalen_george
11/24/2022, 8:34 AMalen_george
11/24/2022, 8:34 AMrp_st
11/24/2022, 8:34 AMrp_st
11/24/2022, 8:34 AMrp_st
11/24/2022, 8:34 AMalen_george
11/24/2022, 8:36 AMalen_george
11/24/2022, 8:36 AMrp_st
11/24/2022, 8:36 AMalen_george
11/24/2022, 8:37 AMalen_george
11/24/2022, 8:37 AMrp_st
11/24/2022, 8:39 AMrp_st
11/24/2022, 8:39 AMrp_st
11/24/2022, 8:39 AMrp_st
11/24/2022, 8:39 AMalen_george
11/24/2022, 8:40 AMalen_george
11/24/2022, 8:40 AMalen_george
11/24/2022, 8:41 AMalen_george
11/24/2022, 8:41 AMrp_st
11/24/2022, 8:41 AMrp_st
11/24/2022, 8:42 AMalen_george
11/24/2022, 8:42 AMrp_st
11/24/2022, 8:43 AMrp_st
11/24/2022, 8:43 AMrp_st
11/24/2022, 8:43 AMrp_st
11/24/2022, 8:43 AMalen_george
11/24/2022, 8:44 AMalen_george
11/24/2022, 8:44 AMalen_george
11/24/2022, 8:44 AMrp_st
11/24/2022, 8:44 AMalen_george
11/24/2022, 8:45 AMrp_st
11/24/2022, 8:45 AMalen_george
11/28/2022, 8:57 AMproviders: [
^
ReferenceError: Google is not defined
rp_st
11/28/2022, 8:57 AMalen_george
11/28/2022, 8:58 AMconst ThirdParty = require('supertokens-node/recipe/thirdparty');
rp_st
11/28/2022, 8:58 AMThirdParty.Google.init()
?alen_george
11/28/2022, 9:00 AMThirdParty.init({
signInAndUpFeature: {
providers: [
// We have provided you with development keys which you can use for testing.
// IMPORTANT: Please replace them with your own OAuth keys for production use.
Google({
clientId: "1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com",
clientSecret: "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"
}),
Github({
clientId: "467101b197249757c71f",
clientSecret: "e97051221f4b6426e8fe8d51486396703012f5bd"
}),
Apple({
clientId: "4398792-io.supertokens.example.service",
clientSecret: {
keyId: "7M48Y4RYDL",
privateKey:
"-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----",
teamId: "YWQCXGJRJL",
},
}),
// Facebook({
// clientSecret: "FACEBOOK_CLIENT_SECRET",
// clientId: "FACEBOOK_CLIENT_ID"
// })
]
}
}),
alen_george
11/28/2022, 9:00 AMrp_st
11/28/2022, 9:01 AMrp_st
11/28/2022, 9:01 AMrp_st
11/28/2022, 9:01 AMalen_george
11/28/2022, 9:02 AMalen_george
11/28/2022, 9:18 AMrp_st
11/28/2022, 9:18 AMalen_george
11/28/2022, 9:18 AMalen_george
11/28/2022, 10:24 AMalen_george
11/28/2022, 10:24 AMrp_st
11/28/2022, 10:24 AMrp_st
11/28/2022, 10:25 AMalen_george
11/28/2022, 10:27 AMrp_st
11/28/2022, 10:27 AMalen_george
11/28/2022, 10:27 AMimport { signInAndUp } from "supertokens-web-js/recipe/thirdparty";
async function handleGoogleCallback() {
try {
const response = await signInAndUp();
if (response.status === "OK") {
console.log(response.user)
if (response.createdNewUser) {
// sign up successful
} else {
// sign in successful
}
window.location.assign("/home");
} else {
// SuperTokens requires that the third party provider
// gives an email for the user. If that's not the case, sign up / in
// will fail.
// As a hack to solve this, you can override the backend functions to create a fake email for the user.
window.alert("No email provided by social login. Please use another form of login");
window.location.assign("/auth"); // redirect back to login page
}
} catch (err: any) {
if (err.isSuperTokensGeneralError === true) {
// this may be a custom error message sent from the API by you.
window.alert(err.message);
} else {
window.alert("Oops! Something went wrong.");
}
}
}
rp_st
11/28/2022, 10:27 AMsignInAndUp
should make a network callalen_george
11/28/2022, 10:27 AMalen_george
11/28/2022, 10:29 AMrp_st
11/28/2022, 10:29 AMrp_st
11/28/2022, 10:30 AMalen_george
11/28/2022, 10:31 AMrp_st
11/28/2022, 10:31 AMrp_st
11/28/2022, 10:31 AMrp_st
11/28/2022, 10:31 AMalen_george
11/28/2022, 10:32 AMasync handleGoogleCallback() {
console.log("true");
try {
const response = await signInAndUp();
console.log(response);
if (response.status === "OK") {
console.log(response.user)
if (response.createdNewUser) {
// sign up successful
console.log(response);
} else {
console.log(response);
// sign in successful
}
// window.location.assign("/signup");
} else {
// SuperTokens requires that the third party provider
// gives an email for the user. If that's not the case, sign up / in
// will fail.
// As a hack to solve this, you can override the backend functions to create a fake email for the user.
window.alert("No email provided by social login. Please use another form of login");
window.location.assign("/login"); // redirect back to login page
}
} catch (err: any) {
if (err.isSuperTokensGeneralError === true) {
// this may be a custom error message sent from the API by you.
window.alert(err.message);
} else {
window.alert("Oops! Something went wrong.");
}
}
}
alen_george
11/28/2022, 10:32 AMrp_st
11/28/2022, 10:33 AMrp_st
11/28/2022, 10:33 AMrp_st
11/28/2022, 10:33 AMalen_george
11/28/2022, 10:33 AMalen_george
11/28/2022, 10:34 AMalen_george
11/28/2022, 10:35 AMrp_st
11/28/2022, 10:41 AMrp_st
11/28/2022, 10:42 AMalen_george
11/29/2022, 9:33 AMalen_george
11/29/2022, 9:34 AMalen_george
11/29/2022, 9:34 AMrp_st
11/29/2022, 9:34 AMrp_st
11/29/2022, 9:35 AMalen_george
11/29/2022, 9:35 AMalen_george
11/29/2022, 10:03 AMnkshah2
11/29/2022, 10:03 AMnkshah2
11/29/2022, 10:03 AMalen_george
11/29/2022, 10:04 AMalen_george
11/29/2022, 10:04 AMnkshah2
11/29/2022, 10:05 AMnkshah2
11/29/2022, 10:05 AMrp_st
11/29/2022, 10:05 AMrp_st
11/29/2022, 10:05 AMnkshah2
11/29/2022, 10:05 AMemailPasswordSignUp
wont apply to yourp_st
11/29/2022, 10:06 AMalen_george
11/29/2022, 10:07 AMalen_george
11/29/2022, 10:27 AMnkshah2
11/29/2022, 10:29 AMconsumeCodePOST
alen_george
11/29/2022, 10:37 AMfunctions: (oI) => {
return {
...oI,
consumeCodePOST: async function (input) {
console.log(input);
console.log(oI);
let existingUser = await ThirdPartyPasswordless.getUsersByEmail(input.email);
if (existingUser.length === 0) {
return oI.consumeCodePOST(input);
}
return {
status: "EMAIL_ALREADY_EXISTS_ERROR"
};
},
thirdPartySignInUp: async function (input) {
let existingUser = await ThirdPartyPasswordless.getUsersByEmail(input.email);
if (existingUser.length === 0) {
return oI.thirdPartySignInUp(input);
}
if (existingUser.find(i => i.thirdParty !== undefined && i.thirdParty.id === input.thirdPartyId)) {
// this means we are trying to sign in with the same social login now. So we allow it
return oI.thirdPartySignInUp(input);
}
throw new Error("Cannot sign up as email already exists");
}
}
}
rp_st
11/29/2022, 10:38 AMalen_george
11/29/2022, 10:41 AMnkshah2
11/29/2022, 10:42 AMconsumeCode
is the functionnkshah2
11/29/2022, 10:43 AMalen_george
11/29/2022, 10:48 AMError: SuperTokens core threw an error for a GET request to path: '/recipe/user' with status code: 400 and message: Please provide exactly one of userId, email or phoneNumber
alen_george
11/29/2022, 10:48 AMreturn {
...oI,
consumeCode: async function (input) {
console.log(input);
console.log(oI);
let existingUser = await ThirdPartyPasswordless.getUsersByEmail(input.email);
if (existingUser.length === 0) {
return oI.consumeCode(input);
}
return {
status: "EMAIL_ALREADY_EXISTS_ERROR"
};
},
alen_george
11/29/2022, 10:48 AMrp_st
11/29/2022, 10:49 AMrp_st
11/29/2022, 10:49 AMrp_st
11/29/2022, 10:49 AMrp_st
11/29/2022, 10:50 AMalen_george
11/29/2022, 10:50 AMrp_st
11/30/2022, 9:45 AMalen_george
11/30/2022, 9:49 AMrp_st
11/30/2022, 9:50 AMalen_george
11/30/2022, 9:51 AMrp_st
11/30/2022, 9:52 AMalen_george
11/30/2022, 9:52 AM