Skip to content
This repository was archived by the owner on Mar 22, 2022. It is now read-only.
This repository was archived by the owner on Mar 22, 2022. It is now read-only.

Find "query" is replaced by token #64

Closed

Description

@fastlorenzo

Hello,
In : feathers-authentication/src/client/hooks.js
export let populateSocketParams = function() { return function(hook) { if (hook.params.token) { ** hook.params.query = { token: hook.params.token };** } }; };

You should create a new object and keep the existing params, otherwise every param query passed to the 'find' action is replaced by the token only.

Thanks 👍

Activity

  1. daffl commented on Feb 15, 2016

    @daffl
    Member

    @ekryski Is there a reason for adding the token to the query? Shouldn't it be already set on the socket?

  2. fastlorenzo commented on Feb 15, 2016

    @fastlorenzo
    ContributorAuthor

    A way to fix it could be using the object.assign call

    Lorenzo Bernardi

    On 15 Feb 2016, at 19:28, David Luecke notifications@github.com wrote:

    @ekryski Is there a reason for adding the token to the query? Shouldn't it be already set on the socket?

    —
    Reply to this email directly or view it on GitHub.

  3. marshallswain commented on Feb 15, 2016

    @marshallswain
    Member

    I think this might be related to this issue: feathersjs/feathers#224

  4. marshallswain commented on Feb 15, 2016

    @marshallswain
    Member

    Oh. it's on the query. nm.

  5. fastlorenzo commented on Feb 15, 2016

    @fastlorenzo
    ContributorAuthor

    Changing
    hook.params.query = { token: hook.params.token };
    to
    hook.params.query = Object.assign({}, hook.params.query, { token: hook.params.token });
    fixes the issue.
    Could you integrate the fix or should I create a pull request ?

  6. marshallswain commented on Feb 15, 2016

    @marshallswain
    Member

    Would you mind creating a PR? Thanks.

  7. ekryski commented on Feb 15, 2016

    @ekryski
    Member

    @fastlorenzo thanks for the PR. Let me review. I think it's likely that it's my bad but I want to make sure it doesn't break anything. I haven't had time to write all the tests that I've needed to.

  8. fastlorenzo commented on Feb 15, 2016

    @fastlorenzo
    ContributorAuthor

    @ekryski sure, no issue 👍

  9. fastlorenzo commented on Feb 15, 2016

    @fastlorenzo
    ContributorAuthor

    PS: maybe you should also use the Object.assing for the following line in the same file :
    19: hook.params.headers = {

  10. ekryski commented on Feb 15, 2016

    @ekryski
    Member

    @fastlorenzo ya I think you are right on the headers part. I actually think @daffl might be right and that for sockets we don't need to set the token each time. hook.params.query and hooks.params.data are the only things sent to the server by feathers-client but in the case of sockets because it is a persistent connection we should already have the token on server side.

    So your PR might be moot. I'm going to tinker with it quickly. We might not even need to have that code in there.

  11. fastlorenzo commented on Feb 15, 2016

    @fastlorenzo
    ContributorAuthor

    Indeed, and I think sending the token each time in the query can be an issue, for example if you want to filter the query using a parameter named token.

  12. fastlorenzo commented on Feb 15, 2016

    @fastlorenzo
    ContributorAuthor

    @ekryski I quickly checked by removing the token to be sent in each request and it look ks like it's working, as @daffl said.
    I'll create another pull request for that so you can check it.

  13. fastlorenzo commented on Feb 15, 2016

    @fastlorenzo
    ContributorAuthor

    I added the proposed changes in my PR

  14. daffl commented on Feb 15, 2016

    @daffl
    Member

    That probably means that we don't need populateSocketParams at all anymore right? Besides that, the PR looks great, thank you for your help!

  15. ekryski commented on Feb 15, 2016

    @ekryski
    Member

    @fastlorenzo I'll take a look. Yes, currently token gets filtered out of the query on the server side so that will need to be addressed.

    @daffl you are right that is no longer needed.

  16. ekryski commented on Feb 15, 2016

    @ekryski
    Member

    I've issued a new PR (#67) that addresses all this and adds some more tests.

  17. ekryski commented on Feb 15, 2016

    @ekryski
    Member

    Close by #65 and #67.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions