Git Product home page Git Product logo

api-plugin-accounts's People

Contributors

akarshit avatar aldeed avatar cristiancucunuba avatar delagroove avatar dependabot[bot] avatar focusaurus avatar kieckhafer avatar loan-laux avatar manizuca avatar manueldelreal avatar mikemurray avatar mohannarayana avatar mpaktiti avatar rondlite avatar rosshadden avatar snyk-bot avatar trojanh avatar willopez avatar zenweasel avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-plugin-accounts's Issues

createAccount mutation isn't working when called directly

When calling createAccount directly in GraphiQL (or another interface), the account is not created as expected - null is returned, and no account is seen in the collection. This is / was an existing issue when this package was internal in reaction (src/core-services/account), so we are going ahead with publishing this package, and will revisit.

Add an `invitations` query

Issue Description

This plugin needs an invitation query to list all staff member invites, with paginated results and only allowed to admins.

Add a `customers` query

Issue Description

This plugin needs a customers query, with paginated results and only allowed to admins.

user.id is undefined in updateAccountGroup

Issue Description

When a group is created(every time you create a shop or directly from graphQL), the console always displays this error
Error in "afterAccountGroupCreate" consumer TypeError: Cannot read property '_id' of null

Steps to Reproduce

  1. Start a new reaction project
  2. Create first shop which under-hood creates global groups
  3. See the logs from the API

or you can use the mutation updateAccountGroup directly

Possible Solution

Get userId from the context here instead of user , and replace it in the event

Versions

1.4.4

Error thrown in integration tests

Issue Description

Even though the tests pass, the following error is thrown after almost every test:

  Error in "afterShopCreate" consumer TypeError: Cannot read property '_id' of null
      at /home/circleci/reaction/node_modules/@reactioncommerce/api-plugin-accounts/src/startup/afterShopCreate.js:26:26
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
      at synchronousPromiseLoop (/home/circleci/reaction/node_modules/@reactioncommerce/api-core/src/util/appEvents.js:24:5)
      at synchronousPromiseLoop (/home/circleci/reaction/node_modules/@reactioncommerce/api-core/src/util/appEvents.js:30:5)
      at AppEvents.emit (/home/circleci/reaction/node_modules/@reactioncommerce/api-core/src/util/appEvents.js:53:5)
      at insertPrimaryShop (/home/circleci/reaction/node_modules/@reactioncommerce/api-utils/lib/tests/insertPrimaryShop.js:123:3)
      at Object.<anonymous> (/home/circleci/reaction/tests/integration/api/mutations/updateSimpleInventory/updateSimpleInventory.test.js:106:3)

Steps to Reproduce

  1. run npm run test in reaction.

updateGroupsForAccounts should only be called in createAccount if there are groups to add

Issue Description

The default for customers is to not belong to a group anymore.
In createAccount, groups default to an empty set, which is then passed to:
updateGroupsForAccounts as empty array:

await context.mutations.updateGroupsForAccounts(context.getInternalContext(), {

In updateGroupsForAccounts, the Groups collection is searched for docs matching _id: { $in: [] } which will return no elements.
Next, as the length of matching elements is 0, an error will be thrown:

throw new ReactionError("not-found", "No groups matching the provided IDs were found");

So the implications of this are:

  1. There always is one redundant search in the Groups collection.
  2. Every normal customer account signup will throw an Error.

This error is only present in the latest trunk branch, as in 1.3 there was no updateGroupsForAccounts and instead createAccount would execute addAccountToGroup for each element in groups, therefore just executing 0 times.

(Steps to Reproduce)

I only followed along the code and stumbled on this by accident so far and didn't actually test.

Possible Solution

Check in createAccount if there are actually groups to add, and decide wether to call updateGroupsForAccounts.
Optionally, make updateGroupsForAccounts fail gracefully with just some warning if it was called with groupIds.length < 1.

Versions

trunk

Introduced here: 7c993f0#diff-8da12d48810df3c6da9a60f2945ee716R116

Create updateGroupsForAccounts mutations for bulk editing

Issue Description

I'm re-writing the Accounts page in reaction-admin and I will need a way to bulk-edit the groups field on accounts. Something that can assign/de-assign multiple groups at once to/from multiple accounts at once. Current mutations would need to be ran multiple times if multiple groups are (de-)selected by the user.

Possible Solution

Create an updateGroupsForAccounts mutation, taking a groupIds array instead of a groupId string and an accountIds array instead of an accountId string.

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.