-
Notifications
You must be signed in to change notification settings - Fork 96
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
Wrong ObjectId passed to service methods on nested routes #106
Comments
Can you create a breaking example? The strange object id you're getting makes me think it has something to do with the setup of related services. Also, in this case it shouldn't matter but |
@daffl Apologies for the late response. Not really sure what a good example would be here, but here's the situation as of now. I did change from Anyways, on the front-end, I am using Dart and Polymer. I have a class with the following code: void loadSubscriptions(appId) {
var subs = _feathers.service("products/$appId/subscriptions");
subs.index().then((subscriptions) {
_appDetail.set("subscriptions", subscriptions);
});
} The // TL;DR - Send authed request and return 'data'
@override
Future<List> index([Map params]) {
var completer = new Completer();
// buildRequest basically just adds the JWT to an XHR
// 'basePath' in this case is '/api/v1/products/<id>/subscriptions
var request = buildRequest("$basePath", method: "GET", write: false);
request.onLoad.listen((_) {
completer.complete(request.response["data"]);
});
request.send();
return completer.future;
} Anyways, when I look in Chrome's 'Network' tab, I see a that the request is sent correctly, correct JWT in the Authorization header, etc. The response is just very confusing to me. The URL I first found the error on was Here is relevant output from
I am running Mac OS X El Capitan 10.11. Hopefully this is detailed enough, if you need any more, I will provide. Thanks in advance. I really dig Feathers a lot. |
Are you using authentication on this service? The error message could also come from sending a token that is valid but has the id of a user that doesn't exist. |
Yes, indeed, I am using authentication of this service. I'm wondering, is there any way to see the JWT attached to the request after it is decoded? Is there such thing as a However, I'm not really sure why the JWT would have the ID of a user who doesn't exist. The JWT is from an XHR to /ap/v1/auth/local, so I'm still confused. |
Yes, the token should be in |
Ah, that makes sense. I store the token and user data in localStorage, like the official client. Regardless, I will check out |
Update - I added a simple hook to the service: productSubscriptions.before({
all: [
hook => {
console.log("Dumping token: ", hook.params.token);
},
auth.verifyToken(),
auth.populateUser(),
auth.restrictToAuthenticated(),
auth.associateCurrentUser()
]
}); And now the error I receive changed, and you were right, the JWT is expired.
I took a look back at my code, and although I thought I had a POST to /auth/token, it's not there. I'm going to put it in my client constructor and see how it goes. Hopefully that is the fix. |
Looks like we figured it out 😄 |
I have a REST/WebSockets backend that I set up with
feathers-cli
. It usesfeathers-mongoose
as a data store.It has three main tables -
users
,products
andsubscriptions
. Subscriptions belong to products, and users own both products and subscriptions.Supplementing the
products
service I have a nested service to query subscriptions based on their productId.The data that I am posting to the server looks like this:
However, the server responds with the following 404 error:
No record found for id '57964d07ecaf8e915bee9108'
. This is puzzling. No product, user or subscription in the database has the ObjectId57964d07ecaf8e915bee9108
. So I am wondering why the ID magically transforms on the server-side.The text was updated successfully, but these errors were encountered: