Skip to content
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

ID set to null - Unable to delete with customer ID field. #422

Closed
WilsonMMM opened this Issue Feb 15, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@WilsonMMM
Copy link

WilsonMMM commented Feb 15, 2017

Hi all,

New to Github so not sure what the correct process is for this but I came across a potential issue when fiddling with user set up.

Scenario:
I've been attempting to set up the user access to match what we currently use in a PHP based set up in which everything is based on user IDs instead of an integer ID with unique key on the email address. With this in mind I changed the ID field to be my user_ID field and was able to sign up and login without issue. When it came to testing deletes however, I would receive an error stating it couldn't delete the user of null. After fiddling with it for a bit I found that if I commented out the restrictToOwner function call from the basic verify, populate, restrict setup that the delete would go through without issue.

When I looked into restrict-to-owner.js I could see that a "const id" was being set based off the populated user but the actually get against the user service is using hook.id and not referencing the "id" variable.

const id = hook.params.user[options.idField];

if (id === undefined) {
  throw new Error(`'${options.idField} is missing from current user.'`);
}

// look up the document and throw a Forbidden error if the user is not an owner
return new Promise((resolve, reject) => {
  // Set provider as undefined so we avoid an infinite loop if this hook is
  // set on the resource we are requesting.
  const params = Object.assign({}, hook.params, { provider: undefined });

  return this.get(hook.id, params).then(data => {
  ...

I'm happy to fork and make a change but since I'm new to Github, Nodejs and Feathers I thought I'd pass it by my betters to see if there is a good reason for this first.

@ekryski

This comment has been minimized.

Copy link
Member

ekryski commented Jul 24, 2017

Hey @WilsonMMM! Looks like this got missed. Is this still an issue for you? I'm assuming not given the time. I'm going to close this issue assuming it's been resolved and in order to keep our issues triaged. If it is still an issue feel free to leave a comment and we can re-open. 😄

@ekryski ekryski closed this Jul 24, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.