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

Potentially error #238

Open
sulimenko opened this issue Jul 29, 2023 · 1 comment · May be fixed by #260
Open

Potentially error #238

sulimenko opened this issue Jul 29, 2023 · 1 comment · May be fixed by #260

Comments

@sulimenko
Copy link

in the session recovery example, potential error

application/api/auth.2/restore.js

({
  access: 'public',
  method: async ({ token }) => {
    const restored = context.client.restoreSession(token);
    if (restored) return { status: 'logged' };
    const data = await api.auth.provider.readSession(token);
    return { status: data ? 'logged' : 'not logged' };
  },
});

If the token is not in sessions, we check it in the database, but after that we don't add it to sessions.

Example: context.client.startSession(token, data);

@sulimenko sulimenko reopened this Oct 27, 2023
@KLarpen
Copy link
Contributor

KLarpen commented Dec 15, 2023

Currently the problem is still exist. Way to reproduce:

  1. node server.js
  2. Open browser http://localhost:8000
  3. Open DevConsole: network tab there, click on api ws request and go to"Messages" tab
  4. Check that one of the initial messages was {type: "call", id: 2, method: "auth/signin",…} and the callback was {type: "callback", id: 2, result: {status: "logged"}}
  5. Type in console await api.example.counter(); that reqesting logged endpoint
  6. You will receive successful answer.
  7. Reload the browser tab.
  8. Check that one of the initial messages was {type: "call", id: 2, method: "auth/restore",…} and the callback was {type: "callback", id: 2, result: {status: "logged"}}
  9. Call againawait api.example.counter();
  10. Result: error: {message: "Forbidden", code: 403}.

After deleting the token from localStorage and repeated clean auth/signin it works as expected again.

KLarpen added a commit to KLarpen/Metarhia-Example that referenced this issue Dec 15, 2023
Problem: forbidden access to the logged endpoints after successful `auth/restore`.

Closes: metarhia#238
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

Successfully merging a pull request may close this issue.

2 participants