N
Novu14mo ago
SuPP

novu/headless how to destroy session?

how to correct destroy session?
4 Replies
SuPP
SuPPOP14mo ago
We have a problem in such a case: - the first user logs in, performs some actions on the site that should later display a notification to him - logout - the second user logs in and receives notifications from the first user for init Novu session we use
headlessService = new HeadlessService({
applicationIdentifier: import.meta.env.VITE_NOVU_APP_ID,
backendUrl: import.meta.env.VITE_NOVU_BACKEND_URL,
socketUrl: import.meta.env.VITE_NOVU_SOCKET_URL,
subscriberId: authUser.uuid,
});

await headlessService.initializeSession(...)
headlessService = new HeadlessService({
applicationIdentifier: import.meta.env.VITE_NOVU_APP_ID,
backendUrl: import.meta.env.VITE_NOVU_BACKEND_URL,
socketUrl: import.meta.env.VITE_NOVU_SOCKET_URL,
subscriberId: authUser.uuid,
});

await headlessService.initializeSession(...)
when user logout we use:
headlessService = null;
headlessService = null;
Linear
Linear14mo ago
Pawan Jain
Pawan Jain13mo ago
@SuPP I see we are missing the logout function in headless @SuPP When second user log-in, are you calling initializeSession again? calling initializeSession again should generate new session for this second user and clear old session of first user
Gabi
Gabi13mo ago
the headless on the front-end should be client-only, I think, so it wouldn't really be able to take information from another user. Are you sure you change the subscriber id when you log in? In addition, the socket immediately detects that you are no longer focused on the application or that you have logged out and changes the user status to inactive, I don't think a logout function is needed, it is done automatically.
Want results from more Discord servers?
Add your server