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

User is always undefined in liveQuery triggers #7318

Closed
5 of 6 tasks
dblythy opened this issue Apr 4, 2021 · 3 comments · Fixed by #7296
Closed
5 of 6 tasks

User is always undefined in liveQuery triggers #7318

dblythy opened this issue Apr 4, 2021 · 3 comments · Fixed by #7296
Labels
state:released Released as stable version state:released-beta Released as beta version type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@dblythy
Copy link
Member

dblythy commented Apr 4, 2021

New Issue Checklist

Issue Description

When I improved the session token lookup for LQ triggers from a Parse.Query to use internal Auth, I didn't correctly destructure getAuthForSessionToken. This results in auth.user always null.

Steps to reproduce

it('LiveQuery with ACL', async done => {
    await reconfigureServer({
      liveQuery: {
        classNames: ['Chat'],
      },
      startLiveQueryServer: true,
      verbose: false,
      silent: true,
    });
    const user = new Parse.User();
    user.setUsername('username');
    user.setPassword('password');
    await user.signUp();

    let calls = 0;

    Parse.Cloud.beforeConnect(req => {
      expect(req.event).toBe('connect');
      expect(req.clients).toBe(0);
      expect(req.subscriptions).toBe(0);
      expect(req.useMasterKey).toBe(false);
      expect(req.installationId).toBeDefined();
      expect(req.user).toBeDefined();
      expect(req.client).toBeDefined();
      calls++;
    });

    Parse.Cloud.beforeSubscribe('Chat', req => {
      expect(req.op).toBe('subscribe');
      expect(req.requestId).toBe(1);
      expect(req.query).toBeDefined();
      expect(req.user).toBeDefined();
      calls++;
    });

    Parse.Cloud.afterLiveQueryEvent('Chat', req => {
      expect(req.event).toBe('create');
      expect(req.user).toBeDefined();
      expect(req.object.get('foo')).toBe('bar');
      calls++;
    });

    const chatQuery = new Parse.Query('Chat');
    const subscription = await chatQuery.subscribe();
    subscription.on('create', object => {
      expect(object.get('foo')).toBe('bar');
      expect(calls).toEqual(3);
      done();
    });
    const object = new Parse.Object('Chat');
    const acl = new Parse.ACL(user);
    object.setACL(acl);
    object.set({ foo: 'bar' });
    await object.save();
  });

Actual Outcome

User always null

Expected Outcome

User to be defined

Failing Test Case / Pull Request

  • 🤩 I submitted a PR with a fix and a test case.
  • 🧐 I submitted a PR with a failing test case.

Environment

Server

  • Parse Server version: master

Database

  • System (MongoDB or Postgres): mongodb
@mtrezza mtrezza added type:bug Impaired feature or lacking behavior that is likely assumed ⚡S2 labels Apr 4, 2021
@mtrezza
Copy link
Member

mtrezza commented Apr 4, 2021

I classified this as a bug with severity S2, because there is no known workaround.

@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Nov 1, 2021
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 5.0.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-beta Released as beta version type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants