nip10
03/30/2023, 7:02 PMrp_st
03/31/2023, 6:22 AMnip10
03/31/2023, 10:50 AMnip10
03/31/2023, 10:50 AMrp_st
03/31/2023, 10:51 AMnip10
03/31/2023, 10:53 AMnip10
03/31/2023, 10:55 AMts
input.accessTokenPayload = {
...input.accessTokenPayload,
extraProperty: "hello world",
};
i would do something like this on the frontend
types.d.ts
ts
interface AccessTokenPayload {
extraProperty: string
} & DefaultAccessTokenPayload
rp_st
03/31/2023, 10:56 AMts
interface AccessTokenPayload {
extraProperty: string
}
let accessTokenPayload: AccessTokenPayload = await session.getAccessTokenPayloadSecurely()
nip10
03/31/2023, 11:00 AMnip10
03/31/2023, 11:00 AMrp_st
03/31/2023, 11:00 AMnip10
03/31/2023, 12:18 PMinput.userContext.myProperty
but this approach doesn't work after the signin (because we already called the original impl fn). I found mergeIntoAccessTokenPayload
and it seems to work, is this the correct way to do this ?
snippet for reference
ts
emailPasswordSignInPOST: async function (input) {
if (originalImplementation.emailPasswordSignInPOST === undefined) {
throw Error("Should never come here");
}
input.userContext.propertyPreSignIn = "pre sign in";
let response = await originalImplementation.emailPasswordSignInPOST(input);
if (response.status === "OK") {
// Do some stuff after sign in, get values from the database that we want to add to the access token payload
input.userContext.ignoredProperty = "doesnt work because we already called the originalImpl fn";
// console.log("[E+P] POST SIGN IN LOGIC", input, response);
await response.session.mergeIntoAccessTokenPayload({
propertyPostSignIn: "post sign in - value from database after status OK" });
}
return response;
},
rp_st
03/31/2023, 12:20 PM