funk101
06/05/2022, 2:56 PMrp_st
06/05/2022, 2:57 PMrp_st
06/05/2022, 2:57 PMrp_st
06/05/2022, 2:57 PMaccessTokenPayload, that will be available on the frontend when you do useSessionContextfunk101
06/05/2022, 2:58 PMrp_st
06/05/2022, 2:58 PMfunk101
06/05/2022, 2:58 PMfunk101
06/05/2022, 2:58 PMoverride: {
apis: (originalImplementation) => {
return {
...originalImplementation,
signUpPOST: async function (input) {
if (originalImplementation.signUpPOST === undefined) {
throw Error("Shouldn't come here");
}
try {
const response = await originalImplementation.signUpPOST(
input
);
if (response.status === "OK") {
const formFields = input.formFields;
formFields.push({
id: "userId",
value: response.session.userId,
});
addUser(formFields);
}
return response;
} catch (err) {
serverLogger.error("/config/backendConfig: ", err.message);
}
},
};
},
functions: (originalImplementation) => {
return {
...originalImplementation,
createNewSession: async function (input) {
let userId = input.userId;
// accessible to frontend
input.accessTokenPayload = {
...input.accessTokenPayload,
stripeSellerId: "hello world",
};
input.sessionData = {
...input.sessionData,
stripeSellerId: "hello world",
};
return originalImplementation.createNewSession(input);
},
};
},
},
}),
SessionNode.init(),rp_st
06/05/2022, 2:59 PMrp_st
06/05/2022, 2:59 PMrp_st
06/05/2022, 2:59 PMthis style code snippetsfunk101
06/05/2022, 3:00 PMrp_st
06/05/2022, 3:00 PMfunk101
06/05/2022, 3:00 PMoverride: {
apis: (originalImplementation) => {
return {
...originalImplementation,
signUpPOST: async function (input) {
if (originalImplementation.signUpPOST === undefined) {
throw Error("Shouldn't come here");
}
try {
const response = await originalImplementation.signUpPOST(
input
);
if (response.status === "OK") {
const formFields = input.formFields;
formFields.push({
id: "userId",
value: response.session.userId,
});
addUser(formFields);
}
return response;
} catch (err) {
serverLogger.error("/config/backendConfig: ", err.message);
}
},
};
},
functions: (originalImplementation) => {
return {
...originalImplementation,
createNewSession: async function (input) {
let userId = input.userId;
// accessible to frontend
input.accessTokenPayload = {
...input.accessTokenPayload,
stripeSellerId: "hello world",
};
input.sessionData = {
...input.sessionData,
stripeSellerId: "hello world",
};
return originalImplementation.createNewSession(input);
},
};
},
},
}),
SessionNode.init(),funk101
06/05/2022, 3:00 PMrp_st
06/05/2022, 3:00 PMrp_st
06/05/2022, 3:01 PMaccessTokenPayload will be accessible on the frontend via useSessionContextrp_st
06/05/2022, 3:01 PMstripeSellerId in accessTokenPayload, you don't need to save it in sessionData.funk101
06/05/2022, 3:02 PMconsole.log(useSessionContext()) it's not therefunk101
06/05/2022, 3:02 PMaccessTokenPayload:
[[Prototype]]: Object
doesSessionExist: true
userId: "c3af1584-6d65-43fd-804e-de299f1ccb8a"funk101
06/05/2022, 3:03 PMrp_st
06/05/2022, 3:04 PMconst { accessTokenPayload, userId } = useSessionContext()
console.log(accessTokenPayload)
console.log(userId)funk101
06/05/2022, 3:06 PM{}
c3af1584-6d65-43fd-804e-de299f1ccb8arp_st
06/05/2022, 3:06 PMfunk101
06/05/2022, 3:06 PMrp_st
06/05/2022, 3:06 PMsFrontTokenfunk101
06/05/2022, 3:07 PMfunk101
06/05/2022, 3:07 PMfunk101
06/05/2022, 3:08 PMrp_st
06/05/2022, 3:08 PMrp_st
06/05/2022, 3:08 PMcreateNewSession function on the backend?rp_st
06/05/2022, 3:08 PMrp_st
06/05/2022, 3:08 PMfunk101
06/05/2022, 3:10 PMrp_st
06/05/2022, 3:10 PMreturn originalImplementation.createNewSession(input);funk101
06/05/2022, 3:10 PMfunk101
06/05/2022, 3:10 PMfunk101
06/05/2022, 3:11 PMrp_st
06/05/2022, 3:11 PM.next folder, rebuild and try againrp_st
06/05/2022, 3:11 PMfunk101
06/05/2022, 3:16 PMfunk101
06/05/2022, 3:30 PMfunk101
06/05/2022, 3:30 PMrp_st
06/05/2022, 3:31 PMrp_st
06/05/2022, 3:31 PMfunk101
06/05/2022, 3:34 PMfunk101
06/05/2022, 3:37 PMrp_st
06/05/2022, 3:38 PMrp_st
06/05/2022, 3:38 PMrp_st
06/05/2022, 3:38 PMfunk101
06/05/2022, 3:39 PMrp_st
06/05/2022, 3:40 PMfunk101
06/05/2022, 3:40 PMfunk101
06/05/2022, 5:26 PMrp_st
06/05/2022, 5:26 PMfunk101
06/05/2022, 5:27 PMrp_st
06/05/2022, 5:27 PMfunk101
06/05/2022, 5:31 PMrp_st
06/05/2022, 5:31 PMfunk101
06/05/2022, 5:31 PMconsole.log("stripeSellerId: ", input.accessTokenPayload);funk101
06/05/2022, 5:33 PMrp_st
06/05/2022, 5:34 PMrp_st
06/05/2022, 5:34 PMfunk101
06/05/2022, 5:35 PMfunk101
06/05/2022, 5:36 PMrp_st
06/05/2022, 5:36 PMrp_st
06/05/2022, 5:36 PMfunk101
06/05/2022, 5:37 PMfunk101
06/05/2022, 5:37 PMrp_st
06/05/2022, 5:37 PMfunk101
06/05/2022, 5:40 PMrp_st
06/05/2022, 5:40 PMfunk101
06/05/2022, 5:40 PMrp_st
06/05/2022, 5:40 PMrp_st
06/05/2022, 5:41 PMrp_st
06/05/2022, 5:41 PMrp_st
06/05/2022, 5:41 PMfunk101
06/05/2022, 5:41 PMrp_st
06/05/2022, 5:41 PMrp_st
06/05/2022, 5:41 PMfunk101
06/05/2022, 5:41 PM