Comments (10)
I'll investigate on the support of DDP for this library.
from meteor-apollo-accounts.
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.
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.
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.
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.
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.
@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.
Yes it works fine. I just hoped for a solution that was not dependent on Meteor-accounts.
from meteor-apollo-accounts.
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.
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)
- Remove dependency on graphql-loader HOT 4
- Accessing userId in graphql server context HOT 1
- GraphQL error: Unknown type "HashedPassword"
- Server-side Rendering & Access to user's ID
- Huge delay between when you call loginWithPassword and user object becomes available in context? react-native + apollo 2.0 HOT 1
- Disable Mutation createUser HOT 3
- Has anyone used Accounts.onCreateUser with meteor-apollo-accounts?
- RN: Crash on Android when trying to loginWithFacebook HOT 1
- Use loginWithPassword with hashPassword
- onChangeCallbacks error HOT 2
- `initAccounts` not exported from meteor/nicolaslopezj:apollo-accounts? HOT 1
- Enrollment user flow
- Float cannot represent non numeric value: {} HOT 7
- User Authentication in metoer with mysql
- Possible to not expose createUser to client? HOT 1
- Setup instructions with apollo-boost? HOT 1
- move devDependencies into devDependencies
- Checking if login token is valid HOT 2
- Looking for a mantainer HOT 3
- Client side package . How to set the fields for returning ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-apollo-accounts.