https://supertokens.com/ logo
Title
f

funk101

12/27/2022, 4:16 AM
can someone point me to the doc where you can "destroy" session after a certain amount of time, forcing the user to relogin?
r

rp

12/27/2022, 4:17 AM
Hey @funk101
f

funk101

12/27/2022, 4:18 AM
yes?
hey
r

rp

12/27/2022, 4:18 AM
You mean you want to log the user out even if they are active?
f

funk101

12/27/2022, 4:18 AM
yes sir
r

rp

12/27/2022, 4:18 AM
Right. So you can do that by overriding the refresh API. Start by calling the original implementation to get the session object
Then from the session object, you can get the time the session was created
If that time is before your threshold, then call the revokeSession function on the session object.
Then user should be logged out
f

funk101

12/27/2022, 4:21 AM
not sure where this should take place
r

rp

12/27/2022, 4:21 AM
Refresh function override
In session.init
On the backend
f

funk101

12/27/2022, 4:22 AM
cool
I'm going down the right path here?
override: {
          apis: (originalImplementation) => {
            return {
              ...originalImplementation,
              refresh: async function (input) {
                if (originalImplementation.refresh === undefined) {
                  throw Error("Shouldn't hit this"); // TODO: figure this out
                }
                try {
                  const session = await originalImplementation.refresh(input);
                  console.log("Session: ", session);
                } catch (err) {
                  throw Error(err);
                }
              },
r

rp

12/30/2022, 4:05 AM
Yes
f

funk101

12/30/2022, 4:17 AM
of course that console.log(session) does nothing
r

rp

12/30/2022, 4:19 AM
Please make sure that you are using the other function. I suggest going through the node SDK reference docs. Thanks
f

funk101

12/30/2022, 4:20 AM
so that should be in SessionNode.init(),
?
r

rp

12/30/2022, 4:37 AM
Yes. Once again, pls see our docs.
If you want help that requires a lot of hand holding, you can start a subscription with us for dedicated support. Hope this makes sense