Coder Social home page Coder Social logo

Comments (10)

dbrrt avatar dbrrt commented on June 19, 2024 1

I'll investigate on the support of DDP for this library.

from meteor-apollo-accounts.

dbrrt avatar dbrrt commented on June 19, 2024

I think the aim of this library is to make use of Meteor accounts for user layer in the Backend for any kind of application as front-end, but as this is using standard accounts Meteor remote methods, it should notify that an account is authenticated Meteor side.

The library is also intended to have users features without DDP.

from meteor-apollo-accounts.

zvictor avatar zvictor commented on June 19, 2024

An application like mine, still highly dependent on DDP, would expect loginWithPassword to trigger the same callbacks as Meteor.loginWithPassword. Otherwise, the DDP server is not aware that the user on that connection has changed, and publications don't react to the change.

I suggest we create a callback to be called from tokenDidChange, responsible for that. So far, the code looks something like that:

  onTokenChange(({ userId }) => {
    if (Accounts) {
      Accounts.connection.setUserId(userId); // it updates the frontend
    }
    // TODO: make a DDP call, updating the server
  });

I have no experience working directly with DDP, but I guess we need to make a dummy DDP request, in order to have credentials exchanged and the server updated. Would it be the way to go here? How to achieve that?

from meteor-apollo-accounts.

dbrrt avatar dbrrt commented on June 19, 2024

That's a nice point, but we'll still have the same issue at import step that we had for AsyncStorage in React Native. If Accounts is reachable globally and no specific import is needed that'd be a way to go but less abstract than the current implementation.

from meteor-apollo-accounts.

zvictor avatar zvictor commented on June 19, 2024

I agree that we need to be careful with Meteor code being added to this library as we don't want our apps to become more dependent on it.

The callback I suggested could be an opt-in, executed in a similar way to how we do now with initAccounts(). There could be a syncMeteor() available for that, that would call onTokenChange for us.
This way we would minimize the chances of having a conflict with other environments.

The challenge remains on DDP. Once the callback is in place, what can be done to update the authentication on the DDP server?

from meteor-apollo-accounts.

zvictor avatar zvictor commented on June 19, 2024

so far the best I could get is calling loginWithToken.

  onTokenChange(({ userId, token }) => {
    Meteor.loginWithToken(token, () => {
      // Update Redux store, call callbacks, whatever...
    });
  });

from meteor-apollo-accounts.

dbrrt avatar dbrrt commented on June 19, 2024

@zvictor I think this's one way to solve your problem. Have you been able to got it working ?
This should be done directly in functions in your Meteor client as a callback of a Login call. Do you want an example that implements that approach ?
And sorry for the delay...

from meteor-apollo-accounts.

zvictor avatar zvictor commented on June 19, 2024

Yes it works fine. I just hoped for a solution that was not dependent on Meteor-accounts.

from meteor-apollo-accounts.

dbrrt avatar dbrrt commented on June 19, 2024

That's a really good point, and I'm almost sure that Meteor accounts libraries are required to work on a Meteor Client, and should be installed both on Client and Server if they're both running Meteor.js and if you need you server communicating through DDP with the clients. I've tried to find a workaround to make it possible, but the one you proposed is nice too, especially if it's yet operational.

from meteor-apollo-accounts.

nicolaslopezj avatar nicolaslopezj commented on June 19, 2024

The answer @zvictor posted is great, can you added to the docs?

This library tries to take out the Meteor in the client side, It should work without it

from meteor-apollo-accounts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.