-
Notifications
You must be signed in to change notification settings - Fork 82
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 can't update its own data (401) #125
Comments
Also experiencing this (not using Postgres). If I change the URL in $upsert from |
IIRC, there is an important difference between "PUT /api/people" and "PUT /api/people/:id": the former replaces all properties with the data in the request and deletes any properties not included in the request, while the latter updates only the properties specified by the request and leaves the rest untouched. @raymondfeng @ritch you are more familiar with ACLs than I am. Is it expected that |
Apparently There are two things that can be done. A) Change your Angular app to call updateAttributes instead of save: // before: User.$save();
User.prototype$updateAttributes({ id: user.id }, user); B) Rework the implementation of $save (source) to detect whether the id property is set. If it is, then call |
I would vote for B. On Wednesday, March 4, 2015, Miroslav Bajtoš [email protected]
Nolan Dubeau Sent from my Apple Newton |
As I mentioned in loopbackio/loopback-datasource-juggler#481, another option is to add a new method "prototype.update" that would always update all attributes and which can be used in |
this issue does not seem to be resolved. Currently trying to update customer and it does not seem to have the ownership to do so. |
The documentation online does not seem to be sufficient to cover how to do simple tasks. I have set up the updateAttributes, and even just threw my hands up and gave $owner unlimited access, and still get the Authentication Required error. This tells me that this user is not the owner of his/her data. The documentation is vast, yet seems to leave many of us hanging with inadequate answers to very common issues. I have gone so far as to set the "property": "update" to ALLOW for $everyone, yet I still get Authentication Required. I'm assuming I'm one of thousands of people spending amazing amounts of human hours on these kind of issues, so could someone clarify how to setup the model update ACL effectively? |
@crandmck Maybe you can help out with the docs here? @rhoderunner9 Do you have any suggestions on how to improve it? |
@superkhau is there a bullet list/nutshell version of what the proper solution is here? I can write documentation with examples etc. once I know what the recommended approach is but it's not clear from this thread what it is. Can @bajtos or someone else familiar with the topic clarify the best/proper way to:
Alternately, I can dig in & figure out the solution myself but that is likely to be very time consuming & probably wasted/duplicated effort. |
@bajtos Would know more about the design/intent of the Angular SDK here. With regards to 1 and 2, |
I am afraid I don't have enough bandwidth to look into this issue right now. I'm moving it to |
Please re-assign me when this is ready-for-docs! 🌴 |
@bajtos bump....? |
@davidcheung do you perhaps have bandwidth to help me with this issue? I think we should be able to reproduce this problem in our test suite (enable authentication, create a user, try to update the user via |
yeah this is still a problem, will add to my backlog |
This is still a problem... upsert() is doing a PATCH to I don't like having to modify my lb-services each time we generate it on an update as per @joncarlson's suggestion.... It's so elegant to just do a Dangerous things happen when using Update, and not validating that |
I have run into this issue several times. I think one possible solution is to modify the service generation app that writes the normal interfaces to the same sdk directory, making all the generated classes abstract. A secondary directory (something like "sdk-impl") can be generated if it does not exist, otherwise providing feedback that an interface has changed, and therefore should be verified so that individual modifications are maintained. If the interface to the service hasn't changed, no notification is necessary. If it has changed, then a notification can be specific to the changes. I don't think this would be too difficult. A simple properties file in the pre-existing sdk specifying the previous api could be used to provide information on the changes that need to be addressed in the sdk-impl. I've been maintaining my modifications in a WICHTIG.md file that keeps track of the things that need to be changed each time I generate the sdk, so it'd be nice to rely on my change set. |
The loopback angular model.$save (or Model.update for that matter) defaults to $upsert, which tries a batch update on the server, which is not allowed for just the $owner. The PUT method for a logged in user in the explorer works though.
Difference in calls is (while using same body payload):
explorer PUT: /api/Users/someid (allowed)
loopback-services.js PUT: /api/Users?id=someid (not allowed because of reason mentioned)
output after call from loopback-services.js:
The text was updated successfully, but these errors were encountered: