forked from reactioncommerce/reaction
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request reactioncommerce#5712 from reactioncommerce/releas…
…e-v2.7.0 Release v2.7.0
- Loading branch information
Showing
1,634 changed files
with
12,386 additions
and
5,561 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../no-meteor/mutations/addAccountToGroup.js → ...es/account/mutations/addAccountToGroup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
89 changes: 89 additions & 0 deletions
89
imports/node-app/core-services/account/mutations/createAccount.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import SimpleSchema from "simpl-schema"; | ||
import ReactionError from "@reactioncommerce/reaction-error"; | ||
import sendWelcomeEmail from "../util/sendWelcomeEmail.js"; | ||
|
||
const inputSchema = new SimpleSchema({ | ||
"emails": Array, | ||
"emails.$": { | ||
type: Object, | ||
blackbox: true, | ||
optional: true | ||
}, | ||
"name": { | ||
type: String, | ||
optional: true | ||
}, | ||
"profile": { | ||
type: Object, | ||
blackbox: true, | ||
optional: true | ||
}, | ||
"shopId": String, | ||
"userId": String, | ||
"verificationToken": { | ||
type: String, | ||
optional: true | ||
} | ||
}); | ||
|
||
/** | ||
* @name accounts/createAccount | ||
* @memberof Mutations/Accounts | ||
* @summary Create a new account | ||
* @param {Object} context - GraphQL execution context | ||
* @param {Object} input - Necessary input for mutation. See SimpleSchema. | ||
* @param {Array} [input.emails] - email array to attach to this user | ||
* @param {String} [input.name] - name to display on profile | ||
* @param {String} [input.profile] - Profile object | ||
* @param {String} input.shopId - shop to create account for | ||
* @param {String} input.userId - userId account was created from | ||
* @param {String} [input.verificationToken] - token for account verification | ||
* @return {Promise<Object>} with boolean of found new account === true || false | ||
*/ | ||
export default async function createAccount(context, input) { | ||
inputSchema.validate(input); | ||
const { appEvents, collections, userId: authUserId, userHasPermission } = context; | ||
const { Accounts, Groups } = collections; | ||
const { | ||
emails, | ||
name, | ||
profile, | ||
shopId, | ||
userId, | ||
verificationToken | ||
} = input; | ||
|
||
if (!context.isInternalCall && !userHasPermission(["reaction-accounts", "account/invite"], shopId)) { | ||
throw new ReactionError("access-denied", "Access denied"); | ||
} | ||
|
||
// Create initial account object from user and profile | ||
const account = { | ||
_id: userId, | ||
acceptsMarketing: false, | ||
createdAt: new Date(), | ||
emails, | ||
name, | ||
profile, | ||
shopId, | ||
state: "new", | ||
updatedAt: new Date(), | ||
userId | ||
}; | ||
|
||
const group = await Groups.findOne({ slug: "customer", shopId }); | ||
account.groups = group ? [group._id] : []; | ||
|
||
await Accounts.insertOne(account); | ||
|
||
if (verificationToken) { | ||
await sendWelcomeEmail(context, { shopId, token: verificationToken, userId }); | ||
} | ||
|
||
await appEvents.emit("afterAccountCreate", { | ||
account, | ||
createdBy: authUserId | ||
}); | ||
|
||
return account; | ||
} |
22 changes: 12 additions & 10 deletions
22
...ounts/server/no-meteor/mutations/index.js → .../core-services/account/mutations/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...eor/mutations/removeAccountEmailRecord.js → ...unt/mutations/removeAccountEmailRecord.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.