diff --git a/.meteor/packages b/.meteor/packages index 2092e377446..87f58df5993 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -29,7 +29,7 @@ logging@1.1.17 reload@1.1.11 ejson@1.0.13 less@2.7.9 -service-configuration@1.0.11 +service-configuration mdg:validated-method shell-server@0.2.4 dynamic-import@0.1.1 @@ -93,3 +93,4 @@ johanbrook:publication-collector # Custom Packages abernix:standard-minifier-js@2.1.0-beta.0 +bozhao:accounts-instagram diff --git a/.meteor/versions b/.meteor/versions index d553be9aec3..4fa112a0a02 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -26,6 +26,7 @@ blaze@2.3.2 blaze-html-templates@1.1.2 blaze-tools@1.0.10 boilerplate-generator@1.1.1 +bozhao:accounts-instagram@0.2.2 browser-policy@1.1.0 browser-policy-common@1.0.11 browser-policy-content@1.1.0 diff --git a/client/modules/accounts/components/auth/loginButtons.js b/client/modules/accounts/components/auth/loginButtons.js index a349cb76b67..f7800833f7d 100644 --- a/client/modules/accounts/components/auth/loginButtons.js +++ b/client/modules/accounts/components/auth/loginButtons.js @@ -33,6 +33,7 @@ class LoginButtons extends Component { {this.props.currentView === "loginFormSignInView" && +   } diff --git a/client/modules/accounts/containers/dropdown/mainDropdownContainer.js b/client/modules/accounts/containers/dropdown/mainDropdownContainer.js index 258f0e79837..2865225a81c 100644 --- a/client/modules/accounts/containers/dropdown/mainDropdownContainer.js +++ b/client/modules/accounts/containers/dropdown/mainDropdownContainer.js @@ -70,18 +70,21 @@ class MainDropdownContainer extends Component { function getCurrentUser() { const shopId = Reaction.getShopId(); - const user = Accounts.user(); + const user = Accounts.user() || {}; if (!shopId || typeof user !== "object") { return null; } + // shoppers should always be guests const isGuest = Roles.userIsInRole(user, "guest", shopId); // but if a user has never logged in then they are anonymous const isAnonymous = Roles.userIsInRole(user, "anonymous", shopId); - return isGuest && !isAnonymous ? user : null; + const account = Collections.Accounts.findOne(user._id); + + return isGuest && !isAnonymous ? account : null; } function getUserGravatar(currentUser, size) { diff --git a/client/modules/accounts/helpers/util.js b/client/modules/accounts/helpers/util.js index fb47aab4fa5..3e2bcc7cffc 100644 --- a/client/modules/accounts/helpers/util.js +++ b/client/modules/accounts/helpers/util.js @@ -10,7 +10,8 @@ function capitalize(str) { const providers = { Facebook: {}, Google: {}, - Twitter: {} + Twitter: {}, + Instagram: {} }; providers.Facebook.fields = function () { @@ -34,6 +35,13 @@ providers.Twitter.fields = function () { ]; }; +providers.Instagram.fields = function () { + return [ + { property: "clientId", label: "Client ID" }, + { property: "secret", label: "Client secret" } + ]; +}; + export class ServiceConfigHelper { availableServices() { const services = Package["accounts-oauth"] ? Accounts.oauth.serviceNames() : []; diff --git a/client/modules/accounts/templates/profile/profile.js b/client/modules/accounts/templates/profile/profile.js index 5d053c646d6..b408b02b487 100644 --- a/client/modules/accounts/templates/profile/profile.js +++ b/client/modules/accounts/templates/profile/profile.js @@ -1,7 +1,9 @@ import { Meteor } from "meteor/meteor"; import { Template } from "meteor/templating"; +import { Roles } from "meteor/alanning:roles"; import { ReactiveVar } from "meteor/reactive-var"; import { Reaction } from "/client/api"; +import { i18next } from "/client/api"; import * as Collections from "/lib/collections"; /** @@ -58,6 +60,30 @@ Template.accountProfile.helpers({ return Collections.Accounts.findOne(); }, + /** + * User's display name + * @return {String} display name + */ + displayName() { + const userId = Meteor.userId() || {}; + const user = Collections.Accounts.findOne(userId); + + if (user) { + if (user.name) { + return user.name; + } else if (user.username) { + return user.username; + } else if (user.profile && user.profile.name) { + return user.profile.name; + } + } + + if (Roles.userIsInRole(user._id || user.userId, "account/profile", + Reaction.getShopId())) { + return i18next.t("accountsUI.guest", { defaultValue: "Guest" }); + } + }, + /** * Returns the address book default view * @return {String} "addressBookGrid" || "addressBookAdd" diff --git a/private/data/i18n/en.json b/private/data/i18n/en.json index 06c8f6127a2..9edb15d8a58 100644 --- a/private/data/i18n/en.json +++ b/private/data/i18n/en.json @@ -546,6 +546,7 @@ "facebook": "Facebook", "google": "Google", "github": "GitHub", + "instagram": "Instagram", "meetup": "Meetup", "ok": "Ok", "twitter": "Twitter", diff --git a/server/security/policy.js b/server/security/policy.js index 4d122a29533..edad2494053 100644 --- a/server/security/policy.js +++ b/server/security/policy.js @@ -37,6 +37,7 @@ BrowserPolicy.content.allowOriginForAll("*.facebook.com"); BrowserPolicy.content.allowOriginForAll("*.fbcdn.net"); BrowserPolicy.content.allowOriginForAll("connect.facebook.net"); BrowserPolicy.content.allowOriginForAll("*.googleusercontent.com"); +BrowserPolicy.content.allowOriginForAll("*.cdninstagram.com"); BrowserPolicy.content.allowImageOrigin("fbcdn-profile-a.akamaihd.net"); BrowserPolicy.content.allowImageOrigin("secure.gravatar.com");