undesiredmonk
04/07/2023, 8:28 AMSession.init({
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
createNewSession: async function (input) {
const userInfo = await ThirdPartyEmailPassword.getUserById(
input.userId
);
const userProfile = getUserProfile(userInfo.id);
if (!userProfile.disabledTemporarily) {
return originalImplementation.createNewSession(input);
}
}
}
}
}
})
rp_st
04/07/2023, 8:33 AMts
session = {
getUserId: () => undefined,
getJWTPayload: () => undefined,
revoke: async () => undefined,
updateJWTPayload: async () => undefined,
getHandle: () => undefined,
getAccessTokenLifeTimeMS: () => undefined,
getRefreshTokenLifeTimeMS: () => undefined,
getIDTokenLifeTimeMS: () => undefined,
getAntiCsrfToken: () => undefined,
getIDRefreshToken: () => undefined,
updateAntiCsrfToken: async () => undefined,
updateIDRefreshToken: async () => undefined,
revokeAllSessionsForUser: async () => undefined,
revokeMultipleSessions: async () => undefined,
revokeSession: async () => undefined,
createNewSession: async () => undefined,
};
And this won't really create a session on the frontend.undesiredmonk
04/07/2023, 8:38 AMthirdPartySignInUpPOST
rp_st
04/07/2023, 8:39 AMrp_st
04/07/2023, 8:39 AMundesiredmonk
04/07/2023, 8:41 AMundefined
from createNewSession
throws Type 'undefined' is not assignable to type 'SessionContainerInterface'
rp_st
04/07/2023, 8:41 AMrp_st
04/07/2023, 8:43 AMrp_st
04/07/2023, 8:45 AMrp_st
04/07/2023, 8:46 AMts
createNewSession: async function (input) {
if (input.userContext.isSignUp) {
/**
* The execution will come here only in case
* a sign up API is calling this function. This is because
* only then will the input.userContext.isSignUp === true
* (see above code).
*/
return {
getAccessToken: () => "",
getAccessTokenPayload: () => null,
getExpiry: async () => -1,
getHandle: () => "",
getSessionData: async () => null,
getTimeCreated: async () => -1,
getUserId: () => "",
revokeSession: async () => { },
updateAccessTokenPayload: async () => { },
updateSessionData: async () => { },
mergeIntoAccessTokenPayload: async () => { },
assertClaims: async () => { },
fetchAndSetClaim: async () => { },
getClaimValue: async () => undefined,
setClaimValue: async () => { },
removeClaim: async () => { },
}; // this is an empty session. It won't result in a session being created for the user.
}
return originalImplementation.createNewSession(input);
}
}
}
}
undesiredmonk
04/07/2023, 8:46 AM