Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy token session #281

Closed
MarhiievHE opened this issue Jan 21, 2022 · 1 comment
Closed

Destroy token session #281

MarhiievHE opened this issue Jan 21, 2022 · 1 comment

Comments

@MarhiievHE
Copy link
Member

Currently, the token of logged-in users and sessions is stored in Maps at the Metacom level. They are indirectly accessed from endpoints via the Client class. This class contains methods to create and restore a connection but does not contain a method to close the connection or destroy the token.
Such a method would be useful since, in order to instantly lower the access level of a user who has already logged in, you must either break the connection or remove the token from his session, which is currently impossible to do from the endpoint.
I tried to implement it with the following method in the Client class:

deleteSession(token) {
    const session = sessions.get(token);
    if (!session) return false;
    const channel = channels.get(this);
    if (channel.session) {
      sessions.delete(channel.session.token);
      channel.session = null;
      return true;
    } 
    return false
  }

I'm not sure if this is the best solution, maybe you can make a better implementation or suggest something else to achieve the goal?

@georgolden
Copy link
Member

@MarhiievHE please create PR for this. I think this feature can be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants