Skip to content

Commit

Permalink
Merge pull request #4599 from reactioncommerce/release-1.16.0
Browse files Browse the repository at this point in the history
Release 1.16.0
  • Loading branch information
spencern authored Sep 11, 2018
2 parents 5c58334 + a35ecd9 commit 36d0775
Show file tree
Hide file tree
Showing 128 changed files with 1,221 additions and 915 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ workflows:
- docker-push
filters:
branches:
only: /^release-1\.15\.\d+$/
only: /^release-1\.16\.\d+$/
- deploy-docs:
requires:
- test-unit
Expand Down
23 changes: 7 additions & 16 deletions .snyk
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,12 @@ version: v1.11.0
ignore:
'npm:bootstrap:20160627':
- bootstrap:
reason: We're not going to update to Bootstrap 4 any time soon
expires: '2018-08-26T20:23:03.274Z'
'npm:hoek:20180212':
- '*':
reason: "PR Accepted to tus-node-server which will resolve this vulnerability https://github.com/tus/tus-node-server/pull/120"
expires: '2018-08-26T20:23:03.274Z'
'npm:tunnel-agent:20170305':
- '*':
reason: "PR Accepted to tus-node-server which will resolve this vulnerability https://github.com/tus/tus-node-server/pull/120"
expires: '2018-08-26T20:23:03.274Z'
'npm:cryptiles:20180710':
- '*':
reason: "PR Accepted to tus-node-server which will resolve this vulnerability https://github.com/tus/tus-node-server/pull/120"
expires: '2018-08-26T20:23:03.274Z'
reason: We're not going to update to Bootstrap 4 any time soon
expires: '2018-10-26T20:23:03.274Z'
'npm:chownr:20180731':
- '*':
reason: "waiting on chownr to resolve issue"
expires: '2018-09-01T20:23:03.274Z'
reason: "PR in chownr to resolve issue will require node >= 10.8 https://github.com/isaacs/chownr/pull/15"
expires: '2018-09-29T20:23:03.274Z'
'npm:mem:20180117':
- '*':
reason: String of dependencies that need to be updated - oslocale (PR https://github.com/sindresorhus/os-locale/pull/31) followed by yargs then transliteration
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# v1.16.0
## GraphQL
### Features
- feat: return absolute media URLs from GraphQL (#4565)

## Meteor App
### Features
- feat 4571 Replace all Meteor.userId() with util function (#4582)
- feat: Improve animations and dynamically import animation libraries to reduce bundle size (#4500) .. Resolves #4441

### Fixes
- fix: reaction error swallowing (#4592)
- fix: update file-collections dependency from 0.5.0 to 0.6.0 (#4589)
- fix: null check in email validation (#4520) .. Resolves #4502
- fix: Add missing Shops.layout migration (#4609) .. Resolves #4608


# v1.15.0

## Sitemap Generator
Expand Down
4 changes: 2 additions & 2 deletions client/modules/core/helpers/apps.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import _ from "lodash";
import { Template } from "meteor/templating";
import { Meteor } from "meteor/meteor";
import { Roles } from "meteor/alanning:roles";
import { Reaction } from "/client/api";
import { Packages, Shops } from "/lib/collections";
Expand All @@ -21,6 +20,7 @@ import { Packages, Shops } from "/lib/collections";
* @return {Object[]} returns an array of filtered, structure reactionApps
*/
export function Apps(optionHash) {
const { getUserId } = Reaction;
const filter = {};
const registryFilter = {};
let key;
Expand Down Expand Up @@ -94,7 +94,7 @@ export function Apps(optionHash) {
// This checks that the registry item contains a permissions matches with the user's permission for the shop
const hasPermissionToRegistryItem = item.permissions.indexOf(permission) > -1;
// This checks that the user's permission set have the right value that is on the registry item
const hasRoleAccessForShop = Roles.userIsInRole(Meteor.userId(), permission, Reaction.getShopId());
const hasRoleAccessForShop = Roles.userIsInRole(getUserId(), permission, Reaction.getShopId());

// both checks must pass for access to be granted
if (hasPermissionToRegistryItem && hasRoleAccessForShop) {
Expand Down
30 changes: 0 additions & 30 deletions client/modules/core/helpers/globals.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import _ from "lodash";
import { Session } from "meteor/session";
import { Meteor } from "meteor/meteor";
import { Roles } from "meteor/alanning:roles";

/* eslint "no-extend-native": [2, {"exceptions": ["String"]}] */
/* eslint "no-alert": 0 */

/**
* @name toggleSession
Expand Down Expand Up @@ -56,28 +51,3 @@ export function getCardType(cardNumber) {
}
return "";
}

/**
* @name getGuestLoginState
* @method
* @memberof Helpers
* @todo These should all be removed. PR's happily accepted.
* @summary Determines if a guest checkout is enabled and the login state for users
* @return {Boolean} true if authenticated user
*/
export function getGuestLoginState() {
if (Meteor.userId() === "string" && this.getShopId() && this.allowGuestCheckout()) {
const isGuestFlow = Session.equals("guestCheckoutFlow", true);
const isGuest = Roles.userIsInRole(Meteor.userId(), "guest", this.getShopId());
const isAnonymous = Roles.userIsInRole(Meteor.userId(), "anonymous", this.getShopId());
if (!isGuestFlow && !isGuest && isAnonymous) {
return false;
} else if (!isGuestFlow && isGuest && !isAnonymous) {
return true;
}
} else if (Session.equals("guestCheckoutFlow", true) && _.pluck(Meteor.user()
.emails, "address")) {
return true;
}
return false;
}
6 changes: 2 additions & 4 deletions client/modules/core/helpers/permissions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";
import { Reaction } from "/client/api";

Expand All @@ -8,12 +7,11 @@ import { Reaction } from "/client/api";
* @summary check current user hasPermission, uses [alanning:meteor-roles](http://alanning.github.io/meteor-roles/classes/Roles.html)
* @example {{hasPermission admin userId}}
* @param {String|Array} "permissions"
* @param {String} checkUserId - optional Meteor.userId, default to current
* @param {String} options - object
* @return {Boolean}
*/
Template.registerHelper("hasPermission", (permissions, options) => {
// default to checking this.userId
const loggedInUser = Meteor.userId();
const loggedInUser = Reaction.getUserId();
const shopId = Reaction.getShopId();
// we don't necessarily need to check here
// as these same checks and defaults are
Expand Down
10 changes: 10 additions & 0 deletions client/modules/core/helpers/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { latinLangs, getShopLang } from "/lib/api/helpers";
import { Meteor } from "meteor/meteor";

// dynamic import of slugiy/transliteration.slugify
let slugify;
Expand Down Expand Up @@ -45,3 +46,12 @@ export function getSlug(slugString) {
}
return slug;
}

/**
* @method getUserId
* @summary returns the userId of logged in user (e.g Meteor.userId())
* @return {String} String
*/
export function getUserId() {
return Meteor.userId();
}
15 changes: 8 additions & 7 deletions client/modules/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { localeDep } from "/client/modules/i18n";
import { Packages, Shops, Accounts } from "/lib/collections";
import { Router } from "/client/modules/router";
import { DomainsMixin } from "./domains";
import { getUserId } from "./helpers/utils";

/**
* Reaction core namespace for client code
Expand Down Expand Up @@ -200,7 +201,7 @@ export default {
* @method
* @memberof Core/Client
* @param {String | Array} checkPermissions -String or Array of permissions if empty, defaults to "admin, owner"
* @param {String} checkUserId - userId, defaults to Meteor.userId()
* @param {String} checkUserId - userId, defaults to logged in user ID
* @param {String} checkGroup group - default to shopId
* @return {Boolean} Boolean - true if has permission
*/
Expand All @@ -215,7 +216,7 @@ export default {

let permissions = ["owner"];
let id = "";
const userId = checkUserId || Meteor.userId();
const userId = checkUserId || getUserId();
//
// local roleCheck function
// is the bulk of the logic
Expand Down Expand Up @@ -271,7 +272,7 @@ export default {
// in line 156 setTimeout
//
function validateUserId() {
if (Meteor.userId()) {
if (getUserId()) {
Meteor.clearTimeout(id);
Router.reload();
return roleCheck();
Expand Down Expand Up @@ -368,7 +369,7 @@ export default {
hasAdminAccess(shopId) {
const adminPermissions = ["owner", "admin"];
if (shopId) {
return this.hasPermission(adminPermissions, Meteor.userId(), shopId);
return this.hasPermission(adminPermissions, getUserId(), shopId);
}
return this.hasPermission(adminPermissions);
},
Expand Down Expand Up @@ -397,7 +398,7 @@ export default {
* @method
* @memberof Core/Client
*/
getSellerShopId(userId = Meteor.userId(), noFallback = false) {
getSellerShopId(userId = getUserId(), noFallback = false) {
if (userId) {
const group = Roles.getGroupsForUser(userId, "admin")[0];
if (group) {
Expand Down Expand Up @@ -444,7 +445,7 @@ export default {
// the Accounts collection.
const syncedPackages = ["reaction"];
if (syncedPackages.indexOf(packageName) > -1) {
Accounts.update(Meteor.userId(), {
Accounts.update(getUserId(), {
$set: {
[`profile.preferences.${packageName}.${preference}`]: value
}
Expand Down Expand Up @@ -721,7 +722,7 @@ export default {
const groupPermissions = group.permissions;

// granting invitation right for user with `owner` role in a shop
if (this.hasPermission(["owner"], Meteor.userId(), group.shopId)) {
if (this.hasPermission(["owner"], getUserId(), group.shopId)) {
return true;
}

Expand Down
7 changes: 4 additions & 3 deletions client/modules/core/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Accounts } from "meteor/accounts-base";

import { Reaction, Logger } from "/client/api";
import { userPrefs } from "./main";
import { getUserId } from "./helpers/utils";

/**
* Startup Reaction
Expand All @@ -18,7 +19,7 @@ Meteor.startup(() => {

// Log in anonymous guest users
Tracker.autorun(() => {
const userId = Meteor.userId();
const userId = getUserId();
if (userId) return; // This autorun is only for when we DO NOT have a user

const loggingIn = Tracker.nonreactive(() => Accounts.loggingIn());
Expand All @@ -42,7 +43,7 @@ Tracker.autorun(() => {
});

Tracker.autorun(() => {
const userId = Meteor.userId(); // The only reactive thing in this autorun. Reruns on login/logout only.
const userId = getUserId(); // The only reactive thing in this autorun. Reruns on login/logout only.
if (!userId) return;

// Load data from Accounts collection into the localStorage
Expand Down Expand Up @@ -72,7 +73,7 @@ Tracker.autorun(() => {

// Fine-grained reactivity on only the user preferences
Tracker.autorun(() => {
const userId = Meteor.userId();
const userId = getUserId();
if (!userId) return;

const user = Meteor.users.findOne(userId, { fields: { profile: 1 } });
Expand Down
7 changes: 4 additions & 3 deletions client/modules/core/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SubsManager } from "meteor/meteorhacks:subs-manager";
import { Roles } from "meteor/alanning:roles";
import { Accounts } from "/lib/collections";
import Reaction from "./main";
import { getUserId } from "./helpers/utils";
import { getAnonymousCartsReactive, unstoreAnonymousCart } from "/imports/plugins/core/cart/client/util/anonymousCarts";

export const Subscriptions = {};
Expand All @@ -19,7 +20,7 @@ Subscriptions.Manager = new SubsManager();
*/

Tracker.autorun(() => {
const userId = Meteor.userId();
const userId = getUserId();
Subscriptions.Account = Subscriptions.Manager.subscribe("Accounts");
Subscriptions.UserProfile = Meteor.subscribe("UserProfile", userId);
});
Expand Down Expand Up @@ -47,7 +48,7 @@ Subscriptions.BrandAssets = Subscriptions.Manager.subscribe("BrandAssets");

const cartSubCreated = new ReactiveVar(false);
Tracker.autorun(() => {
const userId = Meteor.userId();
const userId = getUserId();
if (!userId) return;

const account = Accounts.findOne({ userId });
Expand Down Expand Up @@ -79,7 +80,7 @@ function mergeCart(_id, token) {
// call the mergeCart function to merge it into an account cart and destroy
let isMerging = false;
Tracker.autorun(() => {
const userId = Meteor.userId();
const userId = getUserId();
if (!userId) return;

const shopId = Reaction.getCartShopId();
Expand Down
3 changes: 1 addition & 2 deletions client/modules/i18n/currency.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import accounting from "accounting-js";
import { Meteor } from "meteor/meteor";
import { Reaction, Logger } from "/client/api";
import ReactionError from "@reactioncommerce/reaction-error";
import { Shops, Accounts } from "/lib/collections";
Expand All @@ -23,7 +22,7 @@ export function findCurrency(defaultCurrency, useDefaultShopCurrency) {

const shopCurrency = (shop && shop.currency) || "USD";
const user = Accounts.findOne({
_id: Meteor.userId()
_id: Reaction.getUserId()
});
const profileCurrency = user && user.profile && user.profile.currency;
if (typeof shop === "object" && shop.currencies && profileCurrency) {
Expand Down
3 changes: 1 addition & 2 deletions client/modules/i18n/helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";
import { check, Match } from "meteor/check";
import { Reaction, Logger, i18next } from "/client/api";
Expand Down Expand Up @@ -41,7 +40,7 @@ Template.registerHelper("i18n", (i18nKey, i18nMessage) => {
Template.registerHelper("currencySymbol", () => {
const locale = Reaction.Locale.get();
const user = Accounts.findOne({
_id: Meteor.userId()
_id: Reaction.getUserId()
});
const profileCurrency = user.profile && user.profile.currency;
if (profileCurrency) {
Expand Down
2 changes: 1 addition & 1 deletion client/modules/i18n/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Meteor.startup(() => {
// We need to ensure fine-grained reactivity on only the profile.lang because
// user.profile changed frequently and causes excessive reruns
Tracker.autorun(() => {
const userId = Meteor.userId();
const userId = Reaction.getUserId();
const user = userId && Meteor.users.findOne(userId, { fields: { profile: 1 } });
userProfileLanguage.set((user && user.profile && user.profile.lang) || null);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Meteor } from "meteor/meteor";
import React from "react";
import _ from "lodash";
import PropTypes from "prop-types";
Expand Down Expand Up @@ -54,7 +53,7 @@ const GroupsTableCell = (props) => {
if (columnName === "dropdown") {
const groupName = <span className="group-dropdown">{_.startCase(groups[0].name)}</span>;
const ownerGroup = groups.find((grp) => grp.slug === "owner") || {};
const hasOwnerAccess = Reaction.hasPermission("owner", Meteor.userId(), Reaction.getShopId());
const hasOwnerAccess = Reaction.hasPermission("owner", Reaction.getUserId(), Reaction.getShopId());

if (groups.length === 1) {
return groupName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { compose, withProps } from "recompose";
import { registerComponent, composeWithTracker } from "@reactioncommerce/reaction-components";
import { Meteor } from "meteor/meteor";
import { Template } from "meteor/templating";
import { i18next, Logger } from "/client/api";
import { i18next, Logger, Reaction } from "/client/api";
import { Countries } from "/client/collections";
import * as Collections from "/lib/collections";
import getCart from "/imports/plugins/core/cart/client/util/getCart";
Expand Down Expand Up @@ -286,7 +286,7 @@ const handlers = {
* @returns {undefined}
*/
function composer(props, onData) {
const userId = Meteor.userId();
const userId = Reaction.getUserId();
const account = Collections.Accounts.findOne({ userId });
if (!account) {
// Subscription not ready
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function displayName(displayUser) {

function getAdminShortcutIcons() {
// get shortcuts with audience permissions based on user roles
const roles = Roles.getRolesForUser(Meteor.userId(), Reaction.getShopId());
const roles = Roles.getRolesForUser(Reaction.getUserId(), Reaction.getShopId());

return {
provides: "shortcut",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { compose, withProps } from "recompose";
import { registerComponent, composeWithTracker } from "@reactioncommerce/reaction-components";
import { Meteor } from "meteor/meteor";
import { i18next } from "/client/api";
import { i18next, Reaction } from "/client/api";
import { Accounts } from "/lib/collections";
import UpdateEmail from "../components/updateEmail";

Expand Down Expand Up @@ -30,7 +30,7 @@ const handlers = {
};

const composer = (props, onData) => {
const user = Accounts.findOne(Meteor.userId());
const user = Accounts.findOne(Reaction.getUserId());
const email = user.emails.length > 0 ? user.emails[0].address : "";
onData(null, { email });
};
Expand Down
Loading

0 comments on commit 36d0775

Please sign in to comment.